4
默认wpf窗口有白色。所以我应该为背景指定什么颜色,因此它看起来像普通窗口,就像.net 2.0 win apps windows color一样。请帮助WPF窗口背景颜色
默认wpf窗口有白色。所以我应该为背景指定什么颜色,因此它看起来像普通窗口,就像.net 2.0 win apps windows color一样。请帮助WPF窗口背景颜色
您需要使用系统颜色画笔绘制背景。
该SystemColors.ControlBrushKey
property将返回ResourceKey
为适当的SolidColorBrush
。
例如,设置一个按钮的背景,你可以使用下面的代码:
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
WindowTitle="SystemColors Example" Background="White">
<StackPanel Margin="20">
<Button
Background="{DynamicResource {x:Static SystemColors.DesktopBrushKey}}"
Content="Hello, World!" />
</StackPanel>
</Page>
你为什么会在这里使用DynamicResource而不是静态资源?另外,为什么Visual Studio 2012的Intellisense不能识别“x:Static”? – BlueMonkMN 2012-12-29 18:38:25