2011-06-14 58 views

回答

2

单程:

创建一个矩形并将其填充设置为您选择的颜色。
然后将其Grid.RowSpan值设置为大数或行数。

+0

会是透明的?我的意思是我在这一栏中有一些值。 – Relativity 2011-06-14 17:11:16

+0

是的,您放置在网格单元中的所有内容都应呈现在您的矩形前面。您还可以在Visual Studio属性编辑器中调整Rectangle的透明度,并更改RGBA选择部分中的A值。 – 2011-06-14 17:27:17

9

dabble125的答案是完美的,但给你一个样品,并提了一份说明,它在何处放置的矩形看到的代码是很重要的:

<Grid> 
    <Grid.ColumnDefinitions> 
     <ColumnDefinition/> 
     <ColumnDefinition/> 
     <ColumnDefinition/> 
    </Grid.ColumnDefinitions> 

    <!-- this is not a good place for text block. 
      the text block is beneath the rectangle 
      so it would not be seen --> 
    <!--<TextBlock Grid.Column="1" Text="Some Text"/>--> 

    <Rectangle Grid.Column="1" Grid.RowSpan="1000"> 
     <Rectangle.Fill> 
      <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> 
       <GradientStop Color="#FF83FF97" Offset="0" /> 
       <GradientStop Color="White" Offset="1" /> 
      </LinearGradientBrush> 
     </Rectangle.Fill> 
    </Rectangle> 

    <TextBlock Grid.Column="1" Text="Some Text"/> 
</Grid>