Xaml 如何更改整个网格';s特定行的背景色

Xaml 如何更改整个网格';s特定行的背景色,xaml,uwp,Xaml,Uwp,类似于此: <Grid Background="Yellow" Width="300"> <Grid.ColumnDefinitions> <ColumnDefinition Width="50"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions>

类似于此:

<Grid Background="Yellow" Width="300">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="50"/>
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="0"/>
    </Grid.RowDefinitions>
</Grid>


但这将改变整个电网。我只想更改特定行的背景色。如何操作?

在网格内添加另一个网格,如下所示:

<Grid Background="Yellow" Width="300">
     <Grid.ColumnDefinitions>
        <ColumnDefinition Width="50"/>
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="0"/>
    </Grid.RowDefinitions>

    <Grid Background="Blue" Grid.RowSpan="2" Grid.Column="0"/>
</Grid>

在网格内添加另一个网格,如下所示:

<Grid Background="Yellow" Width="300">
     <Grid.ColumnDefinitions>
        <ColumnDefinition Width="50"/>
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="0"/>
    </Grid.RowDefinitions>

    <Grid Background="Blue" Grid.RowSpan="2" Grid.Column="0"/>
</Grid>


您可以将stackpanel放置在特定的行和列上,然后为其提供所需的背景色您可以将stackpanel放置在特定的行和列上,然后为其提供所需的背景色您可以将网格替换为边框以提高某些性能。您可以将网格替换为边框以提高某些性能。