我有DataGrid,我设置:
CellStyle="{StaticResource Style}"
我的风格:
<Style x:Key="Style" TargetType="{x:Type tool:DataGridCell}" >
<Setter Property="Content" Value="QWE" />
</Style>
但细胞没有“qwe”文字。
答案 0 :(得分:1)
设置Template
,然后设置Content
的{{1}} ...
ContentPresenter
然后您可以添加项目,内容将显示为 qwe 。
<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>