views:

12

answers:

1

I'm trying to apply a gradient background to just one row in a XAML Silverlight grid that I've created.

I can do something like this without any trouble:

<Grid>
    <Grid.Background>
        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
            <GradientStop Color="Black" Offset="0" />
            <GradientStop Color="White" Offset="1" />
        </LinearGradientBrush>
    </Grid.Background>

    <Grid.ColumnDefinitions>
        <ColumnDefinition/>
        <ColumnDefinition/>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition/>
        <RowDefinition/>
    </Grid.RowDefinitions>

    <!-- components and various stuffs -->
</Grid>

Unfortunately this applies the gradient to the entire grid.

It seems as though I can't apply a gradient (or even a color) to an individual row definition in the grid. Is it possible?

Thanks!

+2  A: 

Use a Border, and then use Grid.Row and Grid.ColumnSpan to put it in the specific row of the Grid that you want.

<Grid>
   <Grid.ColumnDefinitions>
       <ColumnDefinition/>
       <ColumnDefinition/>
   </Grid.ColumnDefinitions>
   <Grid.RowDefinitions>
       <RowDefinition/>
       <RowDefinition/>
   </Grid.RowDefinitions>

   <Border Grid.Row="1" Grid.ColumnSpan="2">
      <Border.Background>
         <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
            <GradientStop Color="Black" Offset="0" />
            <GradientStop Color="White" Offset="1" />
       </LinearGradientBrush>
      <Border.Background>
   </Border>

   <!-- other controls in the grid -->
</Grid>
Donut
You da man, man.
Mike Cialowicz
Glad I could help.
Donut