Load WPF styles or other Static Resources from an external file or assembly

WpfXamlAssembliesStylesResourcedictionary

Wpf Problem Overview


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?

Wpf Solutions


Solution 1 - Wpf

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>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionShimmy WeitzhandlerView Question on Stackoverflow
Solution 1 - WpfShimmy WeitzhandlerView Answer on Stackoverflow