xaml-coding-guidelines
xaml-coding-guidelines copied to clipboard
Additional guidance - Resources files organization
It can be great to give additional guidance about XAML code structure/organization. This is a draft of such a guidance.
Resources dictionary organisation
Depending on the app size, target platform and usage styles, you may want to choose a specific ResourceDictionary files structure. You can then tweak loading and parsing times for your specific constrains.
If you're working on a project where you don't have a large amount of XAML resource code, you can use the following files structure:
- AppTheme.Constants.xaml: This resource dictionary contains resources like margins, component sizes, etc...
- AppTheme.FontsAndColors.xaml: This resource dictonary contains Font families, font sizes and strings glyh codes for symbol fonts. Because this XAML file can be quite short, we also add all colors and burshes for our app in that same file,
-
AppTheme.Styles.xaml: This file contains only the styles for the app. This XAML file uses resources defined in the
AppTheme.Constants.xaml
andAppTheme.FontsAndColors.xaml
. - AppTheme.DataTemplates.xaml: The general rule for the datatemplates is to declare them within the XAML file where is used. However, if you are using a datatemplate in different XAML pages, you can group them into this ResourceDictionary.