我正在寻找一种颜色的前 48 像素创建一个背景,而它下面的所有内容都是另一种颜色。我创建了一种样式,但是当我尝试使用它时,它会导致手机因“XamlParseException”而崩溃。
<Style x:Key="BackgroundStyle" TargetType="Grid">
<Setter Property="Background">
<Setter.Value>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="48" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid Grid.Row="0" Background="Green" />
<Grid Grid.Row="1" Background="Yellow" />
</Grid>
</Setter.Value>
</Setter>
</Style>
是否可以在 xaml 中做这样的事情,还是我需要使用图像作为背景来创建这种效果?