private void UnsubscribeFromItemsUpdating(GraphItemCollection collection) { if (collection == null) { return; } collection.CollectionChanged -= GraphItemsCollectionChanged; foreach (var item in collection) { item.Updated -= ItemUpdated; } }
private void SubscribeToItemsUpdating(GraphItemCollection collection) { if (collection == null) { return; } collection.CollectionChanged += GraphItemsCollectionChanged; foreach (var item in collection) { PrepareItem(item); } }
public GraphControlBase() { Items = new UIElementCollection(this, this); mInternalItems = new GraphControlItems(); AddLogicalChild(mInternalItems); AddVisualChild(mInternalItems); GraphItems = new GraphItemCollection(); SubscribeToItemsUpdating(GraphItems); mInternalItems.ItemsSource = GraphItems; DataContextChanged += (s, e) => { mInternalItems.DataContext = e.NewValue; }; }