private static void CommandProperty_Changed(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e) { Control element = dependencyObject as Control; if (element != null) { MouseDoubleClickBehavior behavior = GetOrCreateBehavior(element); behavior.Command = e.NewValue as ICommand; } }
private static MouseDoubleClickBehavior GetOrCreateBehavior(Control element) { MouseDoubleClickBehavior behavior = element.GetValue(MouseDoubleClickBehaviorProperty) as MouseDoubleClickBehavior; if (behavior == null) { behavior = new MouseDoubleClickBehavior(element); element.SetValue(MouseDoubleClickBehaviorProperty, behavior); } return(behavior); }
public static void SetMouseDoubleClickBehavior(DependencyObject obj, MouseDoubleClickBehavior value) { obj.SetValue(MouseDoubleClickBehaviorProperty, value); }