我有一个没有标题栏和边框的 WPF 窗口。所以我想根据它是否处于活动状态来更改窗口背景。
我在下面写了代码,但我收到了消息Cannot implicitly convert type 'System.Drawing.Brush' to 'System.Windows.Media.Brush'
。
你能帮我怎么做吗?谢谢!
// This function used for both "Actived" and "Deactived" event
private void window_Activated(object sender, EventArgs e)
{
Background = (IsActive)? System.Drawing.SystemBrushes.ActiveCaption :
System.Drawing.SystemBrushes.InactiveCaption;
}
编辑
当前我的窗口标题栏如果处于活动状态,则具有石灰颜色,如果处于非活动状态,则为灰色,但其他用户可能不同。如何通过代码获取这些颜色?