2012-03-01 20 views
0

私は、DataGridと私が設定されている:WPFToolkitのDataGrid(スタイル)

CellStyle="{StaticResource Style}" 

私のスタイル:

<Style x:Key="Style" TargetType="{x:Type tool:DataGridCell}" > 
    <Setter Property="Content" Value="QWE" /> 
</Style> 

しかし、細胞は "QWE" のテキストを持っていません。

答えて

1

Templateを設定し、あなたがその項目を追加することができ、コンテンツがQWEとして現れますContentPresenter ...

 <Style x:Key="CenterCellStyle" TargetType="{x:Type tool:DataGridCell}"> 
      <Setter Property="Template"> 
       <Setter.Value> 
        <ControlTemplate TargetType="{x:Type tool:DataGridCell}"> 
         <Grid Background="{TemplateBinding Background}"> 
          <ContentPresenter Content="qwe"/> 
         </Grid> 
        </ControlTemplate> 
       </Setter.Value> 
      </Setter> 
     </Style> 

Contentを設定します。

 MyDataGrid.Items.Add(""); 
関連する問題