12

我正在使用几个Grids 来格式化多个GridViewColumn.CellTemplates:

<ListView SharedSizeScope="true">
  <ListView.View>
    <GridView>
      <GridViewColumn>
        <GridViewColumn.CellTemplate>
          <DataTemplate>
            <Grid>
              <Grid.RowDefinitions>
                <RowDefinition SharedSizeGroup="foo" />
                <!-- ... -->

我试图将RowDefinitions (所有列都相同)提取到 a 中Style

<Style TargetType="{x:Type Grid}">
  <Setter Property="RowDefinitions">
    <Setter.Value>
      <RowDefinition SharedSizeGroup="foo" />
      <!-- ... -->

但是编译器抱怨:

错误:无法设置属性设置器“RowDefinitions”,因为它没有可访问的设置访问器。

这很明显,但不是很有帮助。

我如何避免多次指定行定义(另请参阅不要重复自己),而不是编写自定义派生的Grid?

4

1 回答 1

8

Grid 不支持控件模板(信息取自此处,间接取自此处)。

于 2008-12-10T08:41:45.313 回答