WPF,请问这个资源怎么引用?
<Window.Resources>
<Button x:Key="aa" Background="Red"/>
</Window.Resources>
<Grid>
</Grid>
上面有一个button资源,请问,在Grid里面,如何引用资源,并设置button的Foreground属性。
[解决办法]
你应该这么干:
<Window.Resources>
<!--<Button x:Key="aa" Background="Red" -->
<Style TargetType="{x:Type Button}">
<Setter Property="Background" Value="Red"></Setter>
</Style>
</Window.Resources>
<Grid>
<Button Content="Test" ></Button>
</Grid>