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