CollectionViewSource を介してバインドされた ListBox を含むユーザー コントロールを作成しました。ListBox には、ユーザーが複数選択を行うための CheckBox があります。選択したチェックボックスを一番上にしてリストをソートしたいと思います。ユーザーが何かを選択または選択解除するとすぐにこれが機能することを願っています。xaml を介してこれを行うものを見つけることができないようです。私は何を間違っていますか?
私のxamlで
<CollectionViewSource x:Key="SortedItems"
Source="{Binding Items, ElementName=Selector}"
IsLiveSortingRequested="True">
<CollectionViewSource.LiveSortingProperties>
<System:String>IsSelected</System:String>
</CollectionViewSource.LiveSortingProperties>
<CollectionViewSource.SortDescriptions>
<scm:SortDescription PropertyName="IsSelected"
Direction="Descending" />
<scm:SortDescription PropertyName="CodeDescriptionText" />
</CollectionViewSource.SortDescriptions>
</CollectionViewSource>
そして私のリストボックス
<ListBox x:Name="ItemsControl"
SelectionMode="Multiple"
ItemsSource="{Binding Source={StaticResource SortedItems}}"
ItemTemplate="{Binding ItemTemplate, ElementName=Selector}"
ItemContainerStyle="{StaticResource ListBoxItemStyle}"
Grid.Row="1"
Grid.ColumnSpan="3">