views:

21

answers:

2

I've just begun dabbling in putting together a set of controls as assemblies and I'm working on default styling. What I currently have is a UserControl in a project (thanks Reed!) and I'm able to bring that into another project via reference. I plan to add more controls over time to build something of an SDK.

I currently have some hooks that look for resources in the hosting application which either apply the resources to their respective properties, or style out the control via hard coded defaults.

Is it possible to set up resource dictionaries within the project containing the UserControls so they can use those references as the default, instead of hard coding? If so, how do I target them?

(I have a ResourceDictionary set up within the same project as the controls: Resources>Dictionaries>Colors.xaml)

Thanks in advance!

E

A: 

If I'm undestanding correctly you want to create the file "generic.xaml" in the folder "Themes". However, I don't believe automatic styling works with UserControl only with Control. Generally if you trying to make a control that can be stylized and retemplated you want to inherit from Control and not UserControl.

Stephan
A: 

You should really look at creating custom templated controls in library rather than derivatives of UserControls. This will allow projects that reference your library to specify an alternative default style for you controls in the same way as we can for the controls in Microsofts own SDK.

The Creating a New Control by Creating a ControlTemplate topic on MSDN is good starter.

AnthonyWJones
What I'm trying to do is to eliminate the necessity for multiple files, for portability. The goal is to have a set of controls under one assembly that can be referenced for multiple projects. These controls will have exposed properties to allow styling without generating templates. It's a matter of allowing others in the organization to quickly assemble views that conform to our visual guidelines "out-of-the-box".
Eric