ObservableCollectionからデータをプルする単純なListViewがあり、CollectionViewSourceを使用してGroupPropertyDescriptionを設定し、行がグループ化されて表示されるようにしています。次のスタイルを使用して、各グループにエキスパンダーを使用しました。
<Style TargetType="{x:Type GroupItem}" x:Key="listViewGroupStyle">
<Setter Property="Margin" Value="0 0 0 5" />
<Setter Property="Template" >
<Setter.Value>
<ControlTemplate TargetType="{x:Type GroupItem}">
<Expander IsExpanded="False" BorderBrush="{Binding Name, Converter={StaticResource statusForegroundConverter}}" BorderThickness="2" Margin="1">
<Expander.Header>
<Border BorderThickness="3" BorderBrush="{Binding Name, Converter={StaticResource statusBackgroundConverter}}" CornerRadius="6">
<DockPanel TextBlock.FontWeight="Bold" TextBlock.Foreground="{Binding Name, Converter={StaticResource statusForegroundConverter}}">
<TextBlock Text="{Binding Name, Converter={StaticResource statusStringConverter}}" Margin="5 2 2 2" />
<TextBlock Text=" - " Margin="2" />
<TextBlock Text="{Binding Path=ItemCount}" Margin="0 2 5 2"/>
</DockPanel>
</Border>
</Expander.Header>
<Expander.Content>
<ItemsPresenter />
</Expander.Content>
</Expander>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
私が抱えている問題は、実行時にコレクションが頻繁に更新され、そのたびに、開いているかどうかに関係なく、すべてのグループが折りたたまれてしまうことです。
コレクションが再割り当てされた後、ListViewの外観を維持する方法はありますか?