0
ListViewグループ化が完了し、エクスパンダコントロールが追加されます。ListView/DataGridViewは、アイテムが選択されたときにグループ化を展開します。
<ListView.GroupStyle>
<GroupStyle>
<GroupStyle.ContainerStyle>
<Style TargetType="{x:Type GroupItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Expander IsExpanded="{Binding Mode=TwoWay, Path=IsSelected, RelativeSource={RelativeSource AncestorType=ListViewItem, Mode=FindAncestor}}">
<Expander.Header>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Name}" FontWeight="Bold" Foreground="Gray" FontSize="16" VerticalAlignment="Bottom"/>
<TextBlock Text="{Binding ItemCount}" FontSize="22" Foreground="Green" FontWeight="Bold" FontStyle="Italic" Margin="10,0,0,0" VerticalAlignment="Bottom" />
<TextBlock Text=" item(s)" FontSize="22" Foreground="Silver" FontStyle="Italic" VerticalAlignment="Bottom" />
</StackPanel>
</Expander.Header>
<ItemsPresenter/>
</Expander>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</GroupStyle.ContainerStyle>
</GroupStyle>
</ListView.GroupStyle>
IsExpanded
<Expander IsExpanded="{Binding Mode=TwoWay, Path=IsSelected, RelativeSource={RelativeSource AncestorType=ListViewItem, Mode=FindAncestor}}">
のような、私は選択を変更する
lv.SelectedIndex
を設定し、それが動作しません!
わかりません。
AのListViewItemはGroupItemの視覚的な祖先ではありません。これはGroupItemの子です。あなたは特定のグループを選択/拡張しようとしていますか、何をしようとしていますか? – mm8
ListViewItemをGroupItemに変更しますが、機能しません。 検索機能を実装して、リストからキーワードを見つけて、それを自動選択したいとします。だからグループはリストが結果を見つけるときに拡大する必要がある。 –