我有一个用XAML表示的WPF DataGrid。我为我的网格的TableView使用了RowStyle,但还需要为特定单元格设置一些属性。我需要这些单元格具有行样式的属性,并在其上应用单元格样式的额外属性。
我需要的是像这样的东西,尽管它不起作用,因为它说:“目标类型'CellContentPresenter'无法转换为基本类型'GridRowContent'”。
我也尝试了不指定
我是这样使用
我需要的是像这样的东西,尽管它不起作用,因为它说:“目标类型'CellContentPresenter'无法转换为基本类型'GridRowContent'”。
<Style x:Key="MyGridRowStyle"
BasedOn="{StaticResource {themes:GridRowThemeKey ResourceKey=RowStyle}}"
TargetType="{x:Type dxg:GridRowContent}">
<Setter Property="Height"
Value="25" />
<Style.Triggers>
...
</Style.Triggers>
</Style>
<Style x:Key="MyCellStyle"
BasedOn="{StaticResource MyGridRowStyle}"
TargetType="{x:Type dxg:CellContentPresenter}">
<Style.Triggers>
...
</Style.Triggers>
</Style>
我也尝试了不指定
MyCellStyle
的 BasedOn
属性,但那也不起作用。我是这样使用
MyCellStyle
的:<dxg:GridColumn Header="My Header"
FieldName="MyFieldName"
Width="100"
CellStyle="{StaticResource MyCellStyle}" />
在TableView
上,像这样使用MyGridRowStyle
:
RowStyle="{StaticResource MyGridRowStyle}"
如何使单元格样式仅更改MyCellStyle
中指定的属性,并对其他属性使用MyGridRowStyle
中指定的值?