简体   繁体   中英

How to choose between different styles in WPF XAML

I am creating a popup dialog using microsoft's WPF.

The thing is that this popup must support two or more different styles, for instance, depending on how it is called the popup must have a red background and white text in the foreground, or it must have a white background and gray text in the foreground.

What I would like to do is create as many styles as necessary in my xaml file and just choose each of them depending on how the popup was created, therefore I would like to know if it is possible to create something like this (kind of a dynamically applied style) inside the .xaml file, or if it is better to just do this programatically in the code behind.

Also please note that I am using the Visual Studio 2010 with the .NET Framework 4.0.

Thanks,

Felipe

我将定义一个命名样式的枚举,然后使用DataTriggers从包装边框在控件上设置样式。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM