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?
Static Resource - Static resources are the resources which you cannot manipulate at runtime. The static resources are evaluated only once by the element which refers them during the loading of XAML.
WPF supports different types of resources. These resources are primarily two types of resources: XAML resources and resource data files. Examples of XAML resources include brushes and styles. Resource data files are non-executable data files that an application needs.
A resource dictionary is a repository for XAML resources, such as styles, that your app uses. You define the resources in XAML and can then retrieve them in XAML using the {StaticResource} markup extension and {ThemeResource} markup extension s. You can also access resources with code, but that is less common.
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>
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