private void OnItemPropertyPropertyChanged(DataGridItemPropertyBase itemProperty, PropertyChangedEventArgs e) { var rootCollection = ItemsSourceHelper.GetRootCollection(itemProperty); if (rootCollection == null) { return; } using (this.DeferMappingChanged()) { if (string.IsNullOrEmpty(e.PropertyName) || (e.PropertyName == DataGridItemPropertyBase.SynonymPropertyName)) { if (rootCollection == m_detailItemProperties) { this.MapDetailItemProperty(itemProperty); } } if (string.IsNullOrEmpty(e.PropertyName) || (e.PropertyName == DataGridItemPropertyBase.ItemPropertiesInternalPropertyName)) { var itemProperties = itemProperty.ItemPropertiesInternal; if (itemProperties != null) { this.UnregisterItemProperties(itemProperties); this.RegisterItemProperties(itemProperties); if (rootCollection == m_masterItemProperties) { foreach (var childItemProperty in itemProperties) { this.MapMasterItemProperty(childItemProperty); } } else if (rootCollection == m_detailItemProperties) { foreach (var childItemProperty in itemProperties) { this.MapDetailItemProperty(childItemProperty); } } } } } }
private void OnItemPropertyCollectionChanged(DataGridItemPropertyCollection collection, NotifyCollectionChangedEventArgs e) { var rootCollection = ItemsSourceHelper.GetRootCollection(collection); if (rootCollection == null) { return; } if (rootCollection == m_masterItemProperties) { if (e.Action == NotifyCollectionChangedAction.Reset) { throw new NotSupportedException(); } if (e.Action == NotifyCollectionChangedAction.Move) { return; } using (this.DeferMappingChanged()) { if (e.OldItems != null) { foreach (DataGridItemPropertyBase itemProperty in e.OldItems) { this.UnregisterItemProperty(itemProperty); this.UnmapMasterItemProperty(itemProperty); } } if (e.NewItems != null) { foreach (DataGridItemPropertyBase itemProperty in e.NewItems) { this.RegisterItemProperty(itemProperty); this.MapMasterItemProperty(itemProperty); } } } } else if (rootCollection == m_detailItemProperties) { if (e.Action == NotifyCollectionChangedAction.Reset) { throw new NotSupportedException(); } if (e.Action == NotifyCollectionChangedAction.Move) { return; } using (this.DeferMappingChanged()) { if (e.OldItems != null) { foreach (DataGridItemPropertyBase itemProperty in e.OldItems) { this.UnregisterItemProperty(itemProperty); this.UnmapDetailItemProperty(itemProperty); } } if (e.NewItems != null) { foreach (DataGridItemPropertyBase itemProperty in e.NewItems) { this.RegisterItemProperty(itemProperty); this.MapDetailItemProperty(itemProperty); } } } } else { Debug.Fail("The collection should have been either for the master or the detail item properties."); CollectionChangedEventManager.RemoveListener(collection, this); } }