views:

4160

answers:

2

I have a few WPF applications and I want all my styles to be in a shared assembly instead of declaring them in each application separately.

I am looking for a way so I don't have to change all my Style="{StaticResource BlahBlah}" in the existing applications; I just want to add the reference to this style assembly, and delete it from the current application, so it's taken from the assembly.

Is there any way?

+8  A: 

I have found this link really helpful, would like to join you with it.

It's basically (quote):

Referencing an external ResourceDictionary (XAML File):

<Application.Resources>
    <ResourceDictionary Source="MyResources.xaml" />
</Application.Resources>

Referencing an external ResourceDictionary (DLL):

<Application.Resources>
    <ResourceDictionary
        Source="/MyExternalAssembly;component/MyResources.xaml" />
</Application.Resources>
Shimmy
Thanks for this.
Drew Noakes
u r welcomeglad it helped
Shimmy
A: 

is there any way to include this resource dictionary automatically? e.g. the dll is only referenced in my project and I do not need to use the statements above?

Michael
This should be ask as a new question, or as a comment to the previous answer, not as an answer.
Shimmy
But the answer is no, in XAML you must reference it declaratively in order to access its styles etc.
Shimmy