I have multiple silverlight project that I would like to use the same styles, colour scheme, and some templated objects.
How do I accomplish this?
One way to do this would be to create a new silverlight class library which would be your shared theme/style assembly which would be referenced by the other silverlight projects. This assembly would have one or more Resource Dictionary XAML files in it which could define all of your styles, brushes and templates. You could even set up some cascading style hierarchies using the BasedOn attribute of the Style class.
You could then use MergedDictionaries to merge these styles into your application either at the App.xaml-level or on a page-level basis.
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/SharedThemeAssembly;component/MyStyles.xaml"/>
...other ResourceDictionaries to merge in...
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
You would then reference the shared styles / brushes as you normally would any other StaticResource.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With