WPF: How to choose which Generic.xaml to use?

So, I use a class library called MyControls.dll, in which I created several themes: Generic.xaml (where my controls are regular), GenericBlue.xaml (where my controls are blue), etc.

When I use this class library, it automatically selects Generic.xaml. My question is: can I somehow manually choose which GenericXXX.xaml to choose. I want some programs to display in a specific color, and some other programs to display in a different color, etc.

+4
source share
2 answers

You can also manage application resources at runtime and add an xaml file. If you use DynamicResource bindings, this will allow you to switch styles / patterns as you wish.

+1
source

You can make an application-level resource dictionary from your themes, as

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

If you do this, the general set of control libraries will be ignored, and your application will select this theme to determine the appearance of your controls defined in your library!

0
source

Source: https://habr.com/ru/post/1339407/


All Articles