2012-04-27 4 views
8

私が持っている:CustomGridの背景セルの色を設定する簡単な方法は何ですか?

<CustomControl:GridControl ShowCustomGridLines="True" Grid.Column="2" Grid.Row="0"> 
      <Grid.ColumnDefinitions> 
       <ColumnDefinition /> 
      </Grid.ColumnDefinitions> 
      <Grid.RowDefinitions> 
       <RowDefinition /> 
       <RowDefinition /> 
      </Grid.RowDefinitions> 
     <TextBlock Grid.Column="0" Grid.ColumnSpan="3" Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Center" Name="txbCaption" Text="{Binding Caption}" /> 
      <CustomControl:GridControl ShowCustomGridLines="True" Grid.Column="2" Grid.Row="1"> 
       <Grid.ColumnDefinitions> 
        <ColumnDefinition /> 
        <ColumnDefinition /> 
        <ColumnDefinition /> 
       </Grid.ColumnDefinitions> 
       <Grid.RowDefinitions> 
        <RowDefinition /> 
       </Grid.RowDefinitions> 
       <TextBlock Grid.Column="0" Grid.Row="1" Text="П" HorizontalAlignment="Center" VerticalAlignment="Center" /> 
       <TextBlock Grid.Column="1" Grid.Row="1" Text="Ф" HorizontalAlignment="Center" VerticalAlignment="Center" Background="Yellow" /> 
       <TextBlock Grid.Column="2" Grid.Row="1" Text="%" HorizontalAlignment="Center" VerticalAlignment="Center" /> 
      </CustomControl:GridControl> 

私はテキストボックス(背景=「イエロー」)のセルの背景を設定します。テキストボックスがない場合でも、セル全体の背景色を設定する必要があるため、TextBoxの背景を設定することは役に立ちません。

どうすればいいですか?

答えて

11

この領域にはいくつかのタイプのパネルを配置し、背景色を設定できます。例:

<Rectangle Fill="Black" IsHitTestVisible="False" Grid.Column="1" Grid.Row="1"/> 
2

「セル」が何であるかわかりません。そこにパネルを置き、その色を設定します。

5

セル内にボーダーを配置し、ボーダーの背景色プロパティを設定するボーダー内で必要なコントロールを作成します。

<Border Grid.Column="0" Grid.Row="0" Background="#FF3C3C3F"> 
    <TextBlock>Some Text</TextBlock> 
</Border> 
3

行または列の定義でこれを追加し、行または列全体の背景色を設定するには:あなたが行+列を挿入することによって、あなたのセルを指定

<Grid Grid.Row="0" Grid.Column="0" Background="SomeColor"/> 

。 それから、どこにでもテキストボックスを挿入できます。