private static bool FinishesWithZeroOpacity()

in src/Microsoft.Xaml.Behaviors/Core/ExtendedVisualStateManager.cs [588:624]


        private static bool FinishesWithZeroOpacity(FrameworkElement control, FrameworkElement stateGroupsRoot, VisualState state, VisualState previousState)
        {
            // first, check the new state
            if (state.Storyboard != null)
            {
                foreach (Timeline timeline in state.Storyboard.Children)
                {
                    if (!TimelineIsAnimatingRootOpacity(timeline, control, stateGroupsRoot))
                    {
                        continue;
                    }

                    bool gotValue;
                    object value = GetValueFromTimeline(timeline, out gotValue);

                    return (gotValue && value is double && (double)value == 0);
                }
            }

            // if we got here, then see if it's mentioned in the old state, and if so, the new value will be the base
            if (previousState != null && previousState.Storyboard != null)
            {
                foreach (Timeline timeline in previousState.Storyboard.Children)
                {
                    if (!TimelineIsAnimatingRootOpacity(timeline, control, stateGroupsRoot))
                    {
                        continue;
                    }
                }

                double baseOpacity = (double)stateGroupsRoot.GetAnimationBaseValue(UIElement.OpacityProperty);
                return (baseOpacity == 0);
            }

            // if it's not mentioned in either state, then let's just check the current opacity
            return (stateGroupsRoot.Opacity == 0);
        }