public override void Dispose() { MPF.TryCleanupAndDispose(Value); if (_dataDescriptor != null) { _dataDescriptor.Detach(OnPropertyChanged); } base.Dispose(); }
void Detach() { if (!string.IsNullOrEmpty(Property)) { if (_dataDescriptor != null) { _dataDescriptor.Detach(OnPropertyChanged); _dataDescriptor = null; } } else { _bindingProperty.Detach(OnBindingValueChanged); } }
/// <summary> /// Initializes the <see cref="ItemsControl.ItemsSource"/> property with the <see cref="SubItemsProvider"/>. /// </summary> /// <returns><c>true</c>, if the <see cref="ItemsControl.ItemsSource"/> property was changed by this method, else <c>false</c>.</returns> protected virtual bool InitializeSubItemsSource() { SubItemsProvider sip = SubItemsProvider; IEnumerable oldItemsSource = ItemsSource; if (!_contextChangedAttached) { ContextChanged += OnContextChanged; _contextChangedAttached = true; } if (_attachedContextSource != null) { _attachedContextSource.Detach(OnDataContextValueChanged); } _attachedContextSource = DataContext.EvaluatedSourceValue; _attachedContextSource.Attach(OnDataContextValueChanged); object context = Context; if (context == null) { return(false); } ItemsSource = sip == null ? null : sip.GetSubItems(context); if (oldItemsSource == ItemsSource) { return(false); } MPF.TryCleanupAndDispose(oldItemsSource); CheckExpandable(); return(true); }
public void Detach() { if (_attachedToSource) { _sourceDd.Detach(OnSourceChanged); } _attachedToSource = false; if (_attachedToTarget) { _targetDd.Detach(OnTargetChanged); } _attachedToTarget = false; if (_attachedToLostFocus != null) { _attachedToLostFocus.EventOccured -= OnTargetElementEventOccured; } }
/// <summary> /// Will reset all change handler attachments to source property and /// source path properties. This should be called before the evaluation path /// to the binding's source will be processed again. /// </summary> protected void ResetChangeHandlerAttachments() { foreach (AbstractProperty property in _attachedPropertiesCollection) { property.Detach(OnDataContextChanged); } _attachedPropertiesCollection.Clear(); if (_attachedSource != null) { _attachedSource.Detach(OnBindingSourceChange); _attachedSource = null; } if (_attachedSourceObservable != null) { _attachedSourceObservable.ObjectChanged -= OnBindingSourceChange; _attachedSourceObservable = null; } }