.net – the best way to organize WPF styles and ResourceDictionaries in a large project

.netwpfxaml

I have a large WPF application that uses a large number of styles, brushes, and theming. Managing the large number of styles with multiple developers is becoming difficult. Right now, most of our application-wide styles are in one resource dictionary and the theming brushes are each in their own resource dictionary.

The issue is that finding the style that we want to use is difficult because the main resource dictionary has gotten so large. Any recommendations on the best way to reorganize this? I've considered breaking it into separate resource dictionaries for the type of control the style is for. Such as a ButtonStyles.xaml dictionary, but I'm not sure if that is the right way to go.

If anyone has any suggestions on how they organize their large resource dictionaries I'd appreciate it.

Best Solution

Definitely using multiple resource dictionaries is the way to go. The ability to merge resource dictionaries has been a hindrance to Silverlight developers (until 3.0) and a boon to WPF developers since the beginning.

For medium-sized projects, I highly recommend clustering your resources in dictionaries that indicate a particular type, e.g. ButtonStyles.xaml and Brushes.xaml and Images.xaml and so on.

For really big projects where you have multiple contributors to multiple shared resource dictionaries that might be consumed from multiple WPF applications and front-ends, I would recommend creating a whole separate Assembly that contains all of your resource dictionaries.

I haven't tried this personally, but I've been told that Expression Blend 2 and even more so in Blend 3 has really good GUIs for building and organizing your resource dictionaries and converting per-control styles into resources, etc.