日期:2014-05-20  浏览次数:20969 次

WPf 中,如何为GRID的单元格设定不同的背景色
rt

------解决方案--------------------
C# code


<Grid>
   <Grid.RowDefinitions>
          <RowDefinition Height="0.5*" />
          <RowDefinition Height="0.5*" />
   </Grid.RowDefinitions>
  <Grid.ColumnDefinitions>
         <ColumnDefiniton Width="0.5*"/>
         <ColumnDefiniton Width="0.5*"/>
  </Grid.ColumnDefinitions>
  <Label Grid.Column="0" Grid.Row="0" Background="SpringGreen" ></Label>
  <Label Grid.Column="0" Grid.Row="1" Background="RoyalBlue" ></Label>
  <Label Grid.Column="1" Grid.Row="0" Background="Violet" ></Label>
  <Label Grid.Column="1" Grid.Row="1" Background="Red" ></Label>
</Grid>