Example #1
0
        private static void CommandProperty_Changed(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
        {
            Control element = dependencyObject as Control;

            if (element != null)
            {
                MouseDownBehavior behavior = GetOrCreateBehavior(element);
                behavior.Command = e.NewValue as ICommand;
            }
        }
Example #2
0
        private static MouseDownBehavior GetOrCreateBehavior(Control element)
        {
            MouseDownBehavior behavior = element.GetValue(MouseDownBehaviorProperty) as MouseDownBehavior;

            if (behavior == null)
            {
                behavior = new MouseDownBehavior(element);
                element.SetValue(MouseDownBehaviorProperty, behavior);
            }

            return(behavior);
        }
Example #3
0
 public static void SetMouseDownBehavior(DependencyObject obj,
                                         MouseDownBehavior value)
 {
     obj.SetValue(MouseDownBehaviorProperty, value);
 }