Andreas Grech
Andreas Grech

Reputation: 107950

WPF: Applying styles throught the application

In WPF, where can I put styles that should be applied throughout the application?

This is because currently, whenever I use a style, I put it in the <Window.Resources> section of every window, which ofcourse is wrong in so many ways.

So where can I put these styles to apply throughout?

Upvotes: 1

Views: 1872

Answers (3)

Crippeoblade
Crippeoblade

Reputation: 4065

If you have many styles it could become bloated with Xaml if you put them all in application.resources. Another possibilty is to use resource dictionaries. Here is more info about resource dictionaries and sharing multiple resource dictionaries.

Upvotes: 3

Brette.Net
Brette.Net

Reputation: 148

Generally I will create a seperate project called 'LookAndFeel'. This class contains the App.xaml that defines sall of the style that you want your application to use. If you are doing any kind of module based design it is helpful to have this in a seperate project so you can manage the 'look and feel' in one place. In order to leverage this project you will of course need to create a reference to it.

Upvotes: 0

Rich
Rich

Reputation: 36806

<Application.Resources> in your App.xaml

Upvotes: 6

Related Questions