开发者

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 开发者_如何学Pythonwpf windows?

Best regards Marc


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜