Resource Agreement (WPF) and Management Rules

I just wanted to ask a general question regarding the naming convention that people use for Resource Dictionary (WPF) elements.

In the project that I inherited, I have resource dictionaries around the world with various naming conventions. Therefore, I am looking for suggestions for managing resource dictionaries in general.

Please exclude the topics folder and these resource dictionaries from any answers.

+6
source share
2 answers

I like to use a separate file for different types of resources:

  • Fonts and Fonts (Fonts.xaml)
  • Brushes and colors (Brushes.xaml)
  • General Keyless Management Styles (CoreStyles.xaml)
  • Data Templates and TemplateSelectors (DataTemplates.xaml)
  • Converters (.xaml Converters)
  • BitmapImages for use as image sources (Icons.xaml)
  • Concrete styles with keys (Styles.xaml)
+8
source

I was also interested in agreements for our WPF projects. This pdf was very useful and contains a part about resource management. The author differs from the opinion of BTownTKD:

Before I get into organizing resources, I need to discuss the various philosophies of dividing resources into files. I group them into two approaches:

  • A physical or type-based organization where all instances of a type are grouped together. For example, a resource dictionary will include all constants (or metrics), a separate file for all colors, another file for brushes, etc. I tried this several times and for me it didn't work. This leads to layoffs when you end up including all files and duplicating resources around. It’s also more difficult to navigate through links (for example, from color to brush).
  • A logical organization in which resources are grouped by file to perform a logical task. For example, a group includes all resources for a theme, or all resources used for a specific set of controls (for example, charts) are grouped together as a logical object. Resource files will contain constants, colors, brushes, styles, etc. This approach has proven more effective for many projects, so it is discussed in this article.
+3
source

Source: https://habr.com/ru/post/918020/


All Articles