0
コレクションビューソースを使用してアイテムをフィルタ、グループ化、ソートしていますが、ソース内のコンポーネントを削除または追加するとビューが更新されません。ソースが変更されたときにCollectionViewSourceが更新されない
源:
public ObservableCollection<Component> Components
{
get
{
return mComponents;
}
}
CollectionViewSource:
this.ComponentCollection.Source = this.Components;
this.ComponentCollection.View.Refresh();
これ:
this.ComponentCollection = new CollectionViewSource();
this.ComponentCollection.Source = this.Components;
this.ComponentCollection.GroupDescriptions.Clear();
this.ComponentCollection.GroupDescriptions.Add(new PropertyGroupDescription("Template.ComponentType"));
this.ComponentCollection.SortDescriptions.Clear();
this.ComponentCollection.SortDescriptions.Add(new System.ComponentModel.SortDescription("Name", System.ComponentModel.ListSortDirection.Ascending));
this.ComponentCollection.Filter += this.Filter;
ビューからコンポーネントを追加または削除する唯一の方法は、ソースを再適用することですCollectionViewSourceを使用する方法です:
ItemsSource="{Binding Path=ComponentTemplateCollection.View.Groups}"
私はコレクションのフィルタリングに問題はありませんが、これはうまくいきますが、削除するか、コンポーネントから何かを追加する場合は、this.Components.Remove(x)
は何もしません。
答えがあなたを助けた場合は、回答としてマークしてください。 –