private static void OnVisualStateBehaviorChanged(object sender, DependencyPropertyChangedEventArgs e) { Control control = sender as Control; if (control != null) { VisualStateBehavior newBehavior = (VisualStateBehavior)e.NewValue; if (newBehavior != null) { newBehavior.Attach(control); } } }
/// <summary> /// Sets the value of the VisualStateBehavior attached property. /// Setting the value will attach the behavior to the instance of the control. /// </summary> public static void SetVisualStateBehavior(DependencyObject obj, VisualStateBehavior value) { obj.SetValue(VisualStateBehaviorProperty, value); }
/// <summary> /// Applies the specified behavior to all instances of the target /// control type. /// </summary> /// <param name="behavior">The behavior being registered.</param> public static void RegisterBehavior(VisualStateBehavior behavior) { VisualStateBehaviorFactory.RegisterControlBehavior(behavior); }