/// <summary> /// Called when IsAnimationEnabled is changed on an object. /// </summary> private static void OnIsAnimationEnabledInvalidated(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e) { var panel = dependencyObject as Panel; if (panel == null) { return; } if ((bool)e.NewValue) { // Turn animations on for the panel if there's not already a PanelAnimator attached if (panel.ReadLocalValue(AttachedAnimatorProperty) == DependencyProperty.UnsetValue) { var animator = new PanelLayoutAnimator(panel); panel.SetValue(AttachedAnimatorProperty, animator); } } else { // clear animations if (panel.ReadLocalValue(AttachedAnimatorProperty) != DependencyProperty.UnsetValue) { var animator = (PanelLayoutAnimator)panel.ReadLocalValue(AttachedAnimatorProperty); animator.Detach(); panel.SetValue(AttachedAnimatorProperty, DependencyProperty.UnsetValue); } } }
/// <summary> /// Called when IsAnimationEnabled is changed on an object. /// </summary> private static void OnIsAnimationEnabledInvalidated(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e) { var panel = dependencyObject as Panel; if (panel == null) return; if ((bool)e.NewValue) { // Turn animations on for the panel if there's not already a PanelAnimator attached if (panel.ReadLocalValue(AttachedAnimatorProperty) == DependencyProperty.UnsetValue) { var animator = new PanelLayoutAnimator(panel); panel.SetValue(AttachedAnimatorProperty, animator); } } else { // clear animations if (panel.ReadLocalValue(AttachedAnimatorProperty) != DependencyProperty.UnsetValue) { var animator = (PanelLayoutAnimator)panel.ReadLocalValue(AttachedAnimatorProperty); animator.Detach(); panel.SetValue(AttachedAnimatorProperty, DependencyProperty.UnsetValue); } } }