1
我在ItemsControl中显示了一个扩展器项目列表,并将项目列表绑定到它。 我下面的XAML结构是ItemsControl中的折叠扩展器WPF
<ItemsControl ItemsSource="{Binding}" >
<ItemsControl.ItemTemplate>
<DataTemplate>
<Expander ExpandDirection="Down" Style="{StaticResource ResourceKey=ExpanderItemStyle}" >
<Expander.Header>
<BulletDecorator>
//Expander header by default its collapsed
<Label Style="{StaticResource ResourceKey=ChapterHeadStyle}" Content="{Binding name}"></Label>
</BulletDecorator>
</Expander.Header>
<StackPanel> // Expander body want to collapse it when some some other items of ItemsControl is expanded
</StackPanel>
</Expander>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
我可以当ItemsControl中的其他一些项目被selcted
IsExpanded =“{Binding Mode = TwoWay,Path = IsSelected,RelativeSource = {RelativeSource AncestorType = ListBoxItem,Mode = FindAncestor}}”这种方式对我很有帮助感谢您的帮助:) – 2014-09-19 06:52:00