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