marc40000
marc40000

Reputation: 3198

How to specify WPF Theme in c#?

I found out that I can use a different theme in an C# WPF Application by adding the theme .xaml-file to the project and add

to App.xaml as a Resource. see http://wpf.codeplex.com/wikipage?title=WPF%20Themes for a more detailed description.

Can I do this as well at runtime in C#? Is it possible to specify a different theme for different wpf windows?

Best regards Marc

Upvotes: 0

Views: 4186

Answers (1)

ChrisF
ChrisF

Reputation: 137188

You can share themes between applications and have each one use a different one.

I didn't think you could mix themes within the same application, but marc40000 has found out you can:

<Button Height="23" Margin="81,65,122,0" Name="button1" VerticalAlignment="Top">
    <Button.Resources>
       <ResourceDictionary Source="ShinyBlue.xaml"/>
    </Button.Resources>
    Button
</Button>
<Button Height="23" HorizontalAlignment="Right" Margin="0,0,38,35" Name="button2" VerticalAlignment="Bottom" Width="75">Button</Button>

put the resourcedirectory to the controls you want to theme instead of doing it globaly in the app.xaml

There's even more information from this MSDN page and this one

Upvotes: 1

Related Questions