Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Resource Dictionary (WPF)" naming convention and managing suggestions

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.

like image 222
AMissico Avatar asked Jun 13 '12 19:06

AMissico


2 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)
like image 58
BTownTKD Avatar answered Sep 22 '22 14:09

BTownTKD


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:

  1. 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).
  2. 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.
like image 27
Bruno V Avatar answered Sep 19 '22 14:09

Bruno V