我有以下内容,正在尝试使用另一种语法来设置属性元素,但该按钮现在似乎占据了整个页面:
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Button
x:Name="bluebutton"
Width="100"
Height="40"
Content="Click Me" />
<!--Background="Blue"-->
<Button>
<Button.Background>
<SolidColorBrush Color="Blue" />
</Button.Background>
</Button>
</Page>
如何仍然使用此替代语法,但将颜色应用于bluebutton
?
答案 0 :(得分:1)
您的代码中有两个按钮。也许您想这样做:
<Button
x:Name="bluebutton"
Width="100"
Height="40"
Content="Click Me">
<Button.Background>
<SolidColorBrush Color="Blue" />
</Button.Background>
</Button>