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; } }
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); }
public static void SetMouseDownBehavior(DependencyObject obj, MouseDownBehavior value) { obj.SetValue(MouseDownBehaviorProperty, value); }