public static void SwitchVisualBehavior(DependencyObject d, DependencyPropertyChangedEventArgs e) { IVisualBehavior oldBehavior = e.OldValue as IVisualBehavior; FrameworkElement el = (FrameworkElement)d; if (oldBehavior != null) { oldBehavior.Detach(el); } IVisualBehavior newBehavior = e.NewValue as IVisualBehavior; if (newBehavior != null) { newBehavior.Attach(el); } }
public static void SetTheAttachedBehavior(DependencyObject obj, IVisualBehavior value) { obj.SetValue(TheAttachedBehaviorProperty, value); }