Skip to content

Instantly share code, notes, and snippets.

@JohanLarsson
Created October 23, 2014 16:55
Show Gist options
  • Save JohanLarsson/8d16511744e5fdc0b5e0 to your computer and use it in GitHub Desktop.
Save JohanLarsson/8d16511744e5fdc0b5e0 to your computer and use it in GitHub Desktop.
protected static void OnMyCollectionItemsSourceChanged(DependencyObject property, DependencyPropertyChangedEventArgs args)
{
var newCol = args.NewValue as INotifyCollectionChanged;
if (newCol != null)
{
// CollectionChangedEventManager.AddListener(newCol, this); // You probably wanna do this in a control
newCol.CollectionChanged += OnCollectionChanged;
}
var oldCol = args.OldValue as INotifyCollectionChanged;
if (oldCol != null)
{
//CollectionChangedEventManager.RemoveListener(oldCol, this); //
oldCol.CollectionChanged -= OnCollectionChanged;
}
}
private static void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs notifyCollectionChangedEventArgs)
{
System.Diagnostics.Debug.WriteLine("MyCollection Updated");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment