Just wanted to ask a general question regarding the naming convention people use for "Resource Dictionary (WPF)" items.
In the project I inherited, I have resource dictionaries all over the place with a variety of naming conventions. Therefore, I am looking for suggestions in managing resource dictionaries in general.
Please exclude the Themes folder and those resource dictionaries from any answers.
I like to use a separate file for different resource types:
- Fonts and Font-Sizes (Fonts.xaml)
- Brushes and Colors (Brushes.xaml)
- Generic Control Styles, without keys (CoreStyles.xaml)
- Data Templates and TemplateSelectors (DataTemplates.xaml)
- Converters (Converters.xaml)
- BitmapImages for use as Image sources (Icons.xaml)
- Specific, keyed styles (Styles.xaml)
I was also interested in conventions for our WPF projects.
This pdf was very useful and contains a part about managing Resources. The author differs from opinion with BTownTKD:
Before getting into resource organization, I need to discuss the different philosophies of separating the resources into files.
I group these into two approaches:
- A physical or type-based organization where all instances of a type are grouped together. For example, a resource dictionary would include all constants (or metrics), a separate file for all colors, another file for brushes, and so on. I tried this a few times, and it did not work very well for me. It leads to redundancies where you end up including all files and duplicating resources all around. It is also harder to navigate across references (for example, from the color to the brush).
- A logical organization where resources are grouped on files to accomplish a logical task. For example, a group includes all resources for a theme, or all resources used for a specific set of controls (such as charts) are grouped together as a logical entity. The resources files will include constants, colors, brushes, styles, etc. This approach has proven more efficient on many projects therefore it is the one discussed in this writing.