Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Silverlight: Multiple project sharing the same style files

Tags:

silverlight

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?

like image 851
Shawn Mclean Avatar asked Feb 15 '10 20:02

Shawn Mclean


Video Answer


1 Answers

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.

like image 68
Dan Auclair Avatar answered Oct 29 '22 01:10

Dan Auclair