I’m starting to develop a Desktop application using WPF (.net 3.5 sp1, with VS only, not blend as yet).
I’m at the point were I have some generic reusable components in several libraries.
Where can I define my Styles & Data Templates so that they are reusable across several projects, so I can have a consistent look and feel?
I’ve looked at ResourceDictionaries, but am unsure that
- They’re what I need
- If they are what I need, how I can
‘import’ them into other project and
reference their contents in Xaml.
Thanks,
ResourceDictionary is the way to go, you can either copy an xaml file containing the resource dictionary between projects or compile them into a DLL you’ll reference from your projects.
To reference dictionaries in the same project you add something like this to your App.xaml (in this case I keep my resources in the ControlStyles folder).
If you compile them into a different dll you can use this syntax (if the styles dll is called StyleAssembly, the word “component” is actually part of the syntax and not a directory name):