心如止水

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

本文讲述了对一个ItemsControl中的Items如何实现多个层次的Group。要注意的几个地方是:

1. ItemContainerStyle

<!--ItemContainerStyle means the style for each item's container.

eg, for ListBox, each container is a ListBoxItem, for ComboBox, each container is a ComboBoxItem-->

<ItemsControl.ItemContainerStyle>

<Style>

<Setter Property="Control.Width" Value="100"/>

<Setter Property="Control.Margin" Value="5"/>

</Style>

</ItemsControl.ItemContainerStyle>

这是为每一个Item的container设置的style,例如对于ListBox,这个container就是ListBoxItem。

另外还有一个ItemContainerStyleSelector属性,通过它可以根据自己的需要为不同的Item

Container指定不同的style。

2. ItemsControl.GroupStyle

它是一个ObservableCollection,可以包含多个GroupStyle,即为多个层次的group选择不同的style。

具体参考例子。

3. XmlDataProvider

本例中的source是通过XmlDataProvider提供的。

下载

posted on 2008-11-27 13:47  cutebear  阅读(245)  评论(0编辑  收藏  举报