Shai UI
Shai UI

Reputation: 51958

WPF: How to select which Generic.xaml gets used?

So I'm using a class library called MyControls.dll in this I have set up a few themes: Generic.xaml (where my controls appear regular), GenericBlue.xaml (where my controls appear blue), etc.

When I use this class library it picks Generic.xaml automatically. My question is can I somehow manually pick which GenericXXX.xaml to pick. I'd like some programs to appear a certain color, and some other programs to appear in another color, etc.

Upvotes: 4

Views: 441

Answers (2)

Emond
Emond

Reputation: 50682

You could also manipulate the application's resources at run-time in code and add a xaml file. If you use DynamicResource bindings it will allow you to switch styles/templates at will.

Upvotes: 1

Sarfaraz Nawaz
Sarfaraz Nawaz

Reputation: 361672

You can make a resource dictionary at Application level out of your themes, as

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

If you do this, your control library generic will be ignored, and your application will pick this theme to define the look-and-feel of your controls defined in your library!

Upvotes: 0

Related Questions