【问题标题】:Using an ItemsControl in a grouped ListView在分组的 ListView 中使用 ItemsControl
【发布时间】:2014-01-26 13:57:35
【问题描述】:

我正在尝试使用 ItemsControl - 而不是 ItemsPresenter- 来呈现 GroupItem 的项目,但找不到要绑定的正确属性。

<ControlTemplate TargetType="{x:Type GroupItem}">
 <Expander Header="{Binding Name}">
  <ItemsControl 
    ItemsSource="{Binding RelativeSource={RelativeSource TemplatedParent},Path=??}"/>
   <!--<ItemsPresenter  />-->
 </Expander>
</ControlTemplate>

我使用的任何属性都不会显示任何内容 那么用作 ItemsSource 的 GroupItem 的属性是什么?

提前致谢。

【问题讨论】:

  • 我现在无法检查,是GroupItems吗?
  • @Chris 试过但没用

标签: wpf data-binding controltemplate


【解决方案1】:

每个组由CollectionViewGroup 的一个实例表示,该实例发布Items 属性:

<ControlTemplate TargetType="{x:Type GroupItem}">
   <Expander Header="{Binding Name}">
      <ItemsControl ItemsSource="{Binding Items}"/>
   </Expander>
</ControlTemplate>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多