Beispiel #1
0
        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;
            }
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
 public static void SetActivatedBehavior(DependencyObject obj,
                                         ActivatedBehavior value)
 {
     obj.SetValue(ActivatedBehaviorProperty, value);
 }