【发布时间】:2010-12-03 13:52:50
【问题描述】:
如何将主题的默认窗口背景颜色绑定到窗口背景?
我尝试了以下方法:
<Window x:Class="Shell"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Shell"
Height="300"
Width="300"
Background="{DynamicResource WindowBackgroundBrush}"
>
但是背景颜色呈现为黑色,并且在使用 Luna 主题时看起来不正确。使用 Luna 主题,我预计 Windows XP 中常见的米色/棕色。
更新:在阅读了您的答案、使用StyleSnooper 并对此进行了更多思考后,我得出了以下结论:
默认情况下,窗口将使用 SystemColors.WindowBrush 作为其背景颜色。在我尝试过的大多数主题中,这种颜色都是白色的,这可能没问题。我相信白色也是 WinForms 中的窗口背景颜色。但是,WinForms 中默认的 Form 背景颜色不是 Window 背景而是 Control。所以,如果我想要那种颜色,我会使用SystemColors.ControlBrush,正如Lucas 所指出的那样。
有一次,我试图在 Windows XP 上实现 WinForms 的棕色/米色控件颜色。这在 Windows Vista 上可能是不可能的,因为 Vista 上的控制颜色是灰色的。在 Windows Vista 上运行 WinForms 应用程序不会将其呈现为米色/棕色,而是灰色。在这种情况下,我想我们必须应用我们自己的自定义样式才能在 Vista 上实现“原始”Windows XP 外观。
感谢大家帮我解决这个问题!
【问题讨论】:
-
你解决了吗?我想更改触发器的背景。
标签: .net wpf data-binding xaml themes