且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在WPF中设置按钮的背景色?

更新时间:2023-10-03 09:23:52

根据文档


DevExpress提供可以应用于WPF的所有
DevExpress控件和某些标准控件(GroupBox,
ScrollViewer,Scroll,RadioButton,Button,ListBox,Slider,
TabControl,Separator,ToggleButt)的多个主题

DevExpress provides multiple themes that can be applied to all DevExpress controls for WPF and some standard controls (GroupBox, ScrollViewer, Scroll, RadoiButton, Button, ListBox, Slider, TabControl, Separator, ToggleButton, RepeatButton, Label, ListBoxItem, TabItem, ToolTip, etc).

您可以看到按钮控件在此处列出。但是在文档中,据说可以通过将 ThemeName 属性设置为 None 来禁用单个控件的主题。因此,您可以仅禁用按钮或其某些父容器的主题并使用自己的样式。

这是示例:

As you can see the Button control is listed here. But then in documentation it is said that you can disable theme of individual control by setting ThemeName attribute to None. So, you can just disable the theme for button or for some of its parent containers and use your own style.
Here is example:

<Button Margin="2" Background="LightGreen" dx:ThemeManager.ThemeName="None" ...>