2

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">
4

2 に答える 2

0

あなたのでは、プロパティをプロパティにItemTemplateバインドしていますか? もしそうなら、あなたがやっているように、そのプロパティをプロパティとして設定できるはずです。そうでない場合は、それあなたがする必要があることです。boolCheckbox.IsCheckedSortDescription.PropertyName

于 2013-09-06T15:40:43.723 に答える