In my application I have a control whose background is set based on the user input, by the following code:
在我的应用程序中,我有一个控件,它的背景是基于用户输入设置的,通过以下代码:
m_ToolBar.Background = (m_IToolbar.UseBackColor) ?
new SolidColorBrush(m_IToolbar.BackColor): m_DefaultWindowsBrush;
where m_IToolbar.UseBackColor is a boolean whether to update the color or not, if not then restore back to the default windows color which i have hardcoded in the initialise method.
m_IToolbar的地方。UseBackColor是一个布尔值,不管是否更新颜色,如果不更新的话,它将恢复到我在initialise方法中硬编码的默认windows颜色。
Is there a way to get the default windows color other than hardcording( which has further problem if I change the windows theme color).
除了硬编码外,还有什么方法可以获得默认的windows颜色吗?
1 个解决方案
#1
0
You can use the SystemColors Class. Specifically the SystemColors.ControlBrush Property
您可以使用SystemColors类。特别是SystemColors。ControlBrush财产
From above link:
从上面的链接:
WPF exposes a swatch of colors that comprise the current Windows system theme. These are available in the SystemColors class as Colors, Brushes, and corresponding ResourceKeys (for binding with dynamic notification of changes to these colors, e.g. if the user switches Windows themes).
WPF公开了包含当前Windows系统主题的颜色的swatch。这些在SystemColors类中可用,如颜色、笔刷和相应的ResourceKeys(用于绑定对这些颜色的更改的动态通知,例如,如果用户切换Windows主题)。
#1
0
You can use the SystemColors Class. Specifically the SystemColors.ControlBrush Property
您可以使用SystemColors类。特别是SystemColors。ControlBrush财产
From above link:
从上面的链接:
WPF exposes a swatch of colors that comprise the current Windows system theme. These are available in the SystemColors class as Colors, Brushes, and corresponding ResourceKeys (for binding with dynamic notification of changes to these colors, e.g. if the user switches Windows themes).
WPF公开了包含当前Windows系统主题的颜色的swatch。这些在SystemColors类中可用,如颜色、笔刷和相应的ResourceKeys(用于绑定对这些颜色的更改的动态通知,例如,如果用户切换Windows主题)。