我正在使用几个
Grid
来格式化多个GridViewColumn.CellTemplate
:<ListView SharedSizeScope="true">
<ListView.View>
<GridView>
<GridViewColumn>
<GridViewColumn.CellTemplate>
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition SharedSizeGroup="foo" />
<!-- ... -->
我试图将所有列都相同的RowDefinition
提取到一个Style
中:
<Style TargetType="{x:Type Grid}">
<Setter Property="RowDefinitions">
<Setter.Value>
<RowDefinition SharedSizeGroup="foo" />
<!-- ... -->
但编译器报错:
Error: 属性设置器 'RowDefinitions' 无法设置,因为它没有可访问的设置访问器。
这有点显而易见,但不太有帮助。
除了编写自定义派生类 Grid
,我怎样才能避免多次指定行定义(也可参见不要重复自己)?