Beispiel #1
0
        /// <summary>
        /// IsTransitioningProperty property changed handler.
        /// </summary>
        /// <param name="d">
        /// TransitioningBackgroundControl that changed its IsTransitioning.
        /// </param>
        /// <param name="e">
        /// Event arguments.
        /// </param>
        private static void OnIsTransitioningPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            TransitioningBackgroundControl source = (TransitioningBackgroundControl)d;

            if (!source.allowIsTransitioningWrite)
            {
                source.IsTransitioning = (bool)e.OldValue;
                throw new InvalidOperationException("IsTransitioningReadOnly");
            }
        }
Beispiel #2
0
        /// <summary>
        /// DynamicBackgroundProperty property changed handler.
        /// </summary>
        /// <param name="d">
        /// TransitioningBackgroundControl that changed its DynamicBackground.
        /// </param>
        /// <param name="e">
        /// Event arguments.
        /// </param>
        private static void OnDynamicBackgroundPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            TransitioningBackgroundControl source = d as TransitioningBackgroundControl;
            Brush value = e.NewValue as Brush;
            Brush old   = e.OldValue as Brush;

            if (source != null)
            {
                source.StartTransition(old, value);
            }
        }
Beispiel #3
0
        /// <summary>
        /// TransitionProperty property changed handler.
        /// </summary>
        /// <param name="d">
        /// TransitioningBackgroundControl that changed its Transition.
        /// </param>
        /// <param name="e">
        /// Event arguments.
        /// </param>
        private static void OnTransitionPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            TransitioningBackgroundControl source = (TransitioningBackgroundControl)d;
            string oldTransition = e.OldValue as string;
            string newTransition = e.NewValue as string;

            if (source.IsTransitioning)
            {
                source.AbortTransition();
            }

            // find new transition
            Storyboard newStoryboard = source.GetStoryboard(newTransition);

            // unable to find the transition.
            if (newStoryboard == null)
            {
                // could be during initialization of xaml that presentationgroups was not yet defined
                if (VisualStates.TryGetVisualStateGroup(source, PresentationGroup) == null)
                {
                    // will delay check
                    source.CurrentTransition = null;
                }
                else
                {
                    // revert to old value
                    source.SetValue(TransitionProperty, oldTransition);

                    throw new ArgumentException(
                              string.Format(CultureInfo.CurrentCulture, "TransitionNotFound {0}", newTransition));
                }
            }
            else
            {
                source.CurrentTransition = newStoryboard;
            }
        }