/// <summary> /// Handles changes to the Event property. /// </summary> private static void OnEventChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { CommandBehaviorBinding binding = GetOrCreateBinding(d); // Rebind the Command to the new event and unregister the old event if one is already created. if (binding.Event != null && binding.Owner != null) { binding.Dispose(); } if (e.NewValue == null) { return; } string eventName = e.NewValue.ToString(); if (string.IsNullOrEmpty(eventName)) { return; } // Bind the new event to the command binding.BindEvent(d, eventName); }
/// <summary> /// Releases unmanaged and - optionally - managed resources. /// </summary> /// <param name="disposing"> /// <c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only /// unmanaged resources. /// </param> protected virtual void Dispose(bool disposing) { if (disposing) { if (_Behavior != null) { _Behavior.Dispose(); _Behavior = null; } } }