Featured post
wpf - what is notifycollectionchangedaction reset value -
i have observable collection...selectabledatacontext<t>
..and in generic class selectabledatacontext<t>
is...having 2 private member variables
- private t item.
- private bool isselected.
when isselected property changes...my collection's changed property not firing .
i think should fire...because it's reset
in inotifycollectionchangedaction
.
this old question benefit of may come across through search did:
notifycollectionchangedaction.reset
means "the content of collection changed dramatically". 1 case reset event raised when call clear()
on underlying observable collection.
with reset event, don't newitems
, olditems
collections in notifycollectionchangedeventargs
parameter.
this means you're better off using "sender" of event reference modified collection , use directly, i.e. assume it's new list.
an example of might like:
((inotifycollectionchanged)stringcollection).collectionchanged += new notifycollectionchangedeventhandler(stringcollection_collectionchanged); ... void stringcollection_collectionchanged(object sender, notifycollectionchangedeventargs e) { switch (e.action) { case notifycollectionchangedaction.add: foreach (string s in e.newitems) { internaladd(s); } break; case notifycollectionchangedaction.remove: foreach (string s in e.olditems) { internalremove(s); } break; case notifycollectionchangedaction.reset: readonlyobservablecollection<string> col = sender readonlyobservablecollection<string>; internalclearall(); if (col != null) { foreach (string s in col) { internaladd(s); } } break; } }
lots of discussions on reset event here: when clearing observablecollection, there no items in e.olditems.
- Get link
- X
- Other Apps
Comments
Post a Comment