嘗試從XAML執行此操作。
< Window x:Class="WPF1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525" >
<Grid Background="{DynamicResource {x:Static SystemColors.InactiveCaptionTextBrushKey}}">
</Grid>
這也是動態資源
<Window x:Class="WPF1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Background="{DynamicResource WindowBrush}"
Title="MainWindow" Height="350" Width="525" >
<Window.Resources>
<SolidColorBrush x:Key="WindowBrush" Color="LightGray"/>
</Window.Resources>
<Grid >
</Grid>
</Window>
它也可以與靜態資源
確定myWindow1是窗口的一個實例。它應該有一個背景屬性。你也不能寫新的myWindow1() – 2015-04-01 17:52:12
如何在創建實例時使用MyWindow1方法? – user2526236 2015-04-01 17:54:07