【发布时间】:2012-02-07 09:00:30
【问题描述】:
谁能帮我解决这个问题(c# wpf):
我有一个ListView 和这个Style 用于我的Expander(每个组):
<ListView.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Path=Name}" />
</StackPanel>
</DataTemplate>
</GroupStyle.HeaderTemplate>
<GroupStyle.ContainerStyle>
<Style TargetType="{x:Type GroupItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type GroupItem}">
<Expander IsExpanded="False">
<Expander.Header>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=Name}" />
</StackPanel>
</Expander.Header>
<ItemsPresenter />
</Expander>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</GroupStyle.ContainerStyle>
</GroupStyle>
</ListView.GroupStyle>
当用户展开Expander时,我想选择展开组中的第一项。
我这样添加了我的组(CustomerOrderList = ListView):
CustomerOrderList.ItemsSource = OrderDetails.DefaultView;
CollectionView cv = (CollectionView)CollectionViewSource.GetDefaultView(CustomerOrderList.ItemsSource);
PropertyGroupDescription pgd = new PropertyGroupDescription("OrderInfo");
cv.GroupDescriptions.Add(pgd);
这可能吗?
谢谢, 森内
【问题讨论】:
标签: c# wpf xaml listview expander