Dispose() public method

Unregisters the EventHandler from the Event
public Dispose ( ) : void
return void
Beispiel #1
0
        /// <summary>
        /// Handles changes to the Event property.
        /// </summary>
        private static void OnEventChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            CommandBehaviorBinding binding = FetchOrCreateBinding(d);

            //check if the Event is set. If yes we need to rebind the Command to the new event and unregister the old one
            if (binding.Event != null && binding.Owner != null)
            {
                binding.Dispose();
            }
            //bind the new event to the command
            binding.BindEvent(d, e.NewValue.ToString());
        }
Beispiel #2
0
        /// <summary>
        /// Handles changes to the Event property.
        /// </summary>
        private static void OnEventChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            if (DesignerProperties.GetIsInDesignMode(d))
            {
                return;
            }

            CommandBehaviorBinding binding = FetchOrCreateBinding(d);

            //check if the Event is set. If yes we need to rebind the Command to the new event and unregister the old one
            if (binding.Event != null && binding.Owner != null)
            {
                binding.Dispose();
            }

            //if (string.IsNullOrEmpty((string)e.NewValue))

            //    return;

            //bind the new event to the command
            binding.BindEvent(d, e.NewValue.ToString());
        }