2 つの s (および)にバインドする必要があるObservableCollection<MyClass>名前があります。myCollectionCollectionViewSourceAllItemsSelectedItems
AllItemsの source プロパティは にバインドされていmyCollectionます。SelectedItemsのソース プロパティは、myCollectionアイテムにバインドする必要がありIsSelected == trueます。
public class MyClass : INotifyPropertyChanged
{
//fields and interface implementations
public string Name {//proper code};
public bool? IsSelected {//proper code};
}
// some where else in the MainWindow
AllItems.Source = myCollection;
SelectedItems.Source = myCollection.Where(input=>input.IsSelected==true);
問題:ウィンドウが読み込まれると、すべて問題ありません。しかし、 のIsSelectedいくつかのアイテムの値myCollectionが変更されても、明らかに には影響しませんSelectedItems。したがって、この問題を克服するために、プロパティが変更さSelectedItemsれるたびにソース プロパティを更新します。IsSelected
質問:のソース プロパティを手動で更新する必要がないように、これらの種類のバインドを行うにはどうすればよいSelectedItemsですか?
タナクス。