예제 #1
0
        private static void CommandProperty_Changed(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
        {
            var element = dependencyObject as FrameworkElement;

            if (element != null)
            {
                MouseLeftButtonDownBehavior behavior = GetOrCreateBehavior(element);
                behavior.Command = e.NewValue as ICommand;
            }
        }
예제 #2
0
        private static MouseLeftButtonDownBehavior GetOrCreateBehavior(FrameworkElement element)
        {
            MouseLeftButtonDownBehavior behavior = element.GetValue(MouseLeftButtonDownBehaviorProperty) as MouseLeftButtonDownBehavior;

            if (behavior == null)
            {
                behavior = new MouseLeftButtonDownBehavior(element);
                element.SetValue(MouseLeftButtonDownBehaviorProperty, behavior);
            }

            return(behavior);
        }
예제 #3
0
 public static void SetMouseLeftButtonDownBehavior(DependencyObject obj,
                                                   MouseLeftButtonDownBehavior value)
 {
     obj.SetValue(MouseLeftButtonDownBehaviorProperty, value);
 }