سؤال

If I had 2 ObservableCollections<someObject> one represents the ItemsSource and one represents the SelectedItems source.

Does calling the Clear() function on the SelectedItems source remove those items from the ItemsSource?

هل كانت مفيدة؟

المحلول

No it would just affect your SelectedItems collection (by emptying it of course). Clear just removes items from a collection not another one :

  • ItemsSource references an ObservableCollection containing object references.
  • SelectedItems references another ObservableCollection containing some objects references also contained into your ItemsSources collection;

Calling Clear method on your SelectedItems collection will only removes object references contained in SelectedItems, not objects (themself) or object references from another collection (here ItemsSource).

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top