Coming from the WPF world, finding out that Silverlight lacked the feature of distributing application resources among separate files was one of those kick in a head moments. Well, not anymore. Silverlight 3, like its big brother WPF, now supports partitioning resources through merged dictionaries.
Merged resource dictionaries can be included as external files (build action = Content), as included resources (build action = Resource), or as referenced assembly resources (e.g. theming).
<ResourceDictionary Source="Themes/Theme1.xaml" />
<ResourceDictionary Source="Themes/Theme2.xaml" />
Merged resource dictionaries come in useful when:
- providing different themes for the application (like in the sample below)
- providing a new style/template for existing control
- providing a style/template for a custom control
Run the sample online
Source code below: