private static Dictionary GetOldOpacities()

in src/Microsoft.Xaml.Behaviors/Core/ExtendedVisualStateManager.cs [1020:1073]


        private static Dictionary<FrameworkElement, double> GetOldOpacities(FrameworkElement control, FrameworkElement templateRoot, Storyboard layoutStoryboard, List<OriginalLayoutValueRecord> originalValueRecords, List<FrameworkElement> movingElements)
        {
            Dictionary<FrameworkElement, double> oldOpacities = new Dictionary<FrameworkElement, double>();

            // first walk through any elements currently in motion - note that this may include elements from an orthogonal stategroup
            if (movingElements != null)
            {
                foreach (FrameworkElement movingElement in movingElements)
                {
                    WrapperCanvas wrapper = movingElement.Parent as WrapperCanvas;

                    if (wrapper != null)
                    {
                        oldOpacities.Add(movingElement, wrapper.Opacity);
                    }
                }
            }

            // then walk through the elements whose visibility we'll be replacing
            for (int i = originalValueRecords.Count - 1; i >= 0; i--)
            {
                OriginalLayoutValueRecord originalValueRecord = originalValueRecords[i];
                if (IsVisibilityProperty(originalValueRecord.Property))
                {
                    double oldOpacity;

                    if (!oldOpacities.TryGetValue(originalValueRecord.Element, out oldOpacity))
                    {
                        oldOpacity = ((Visibility)(originalValueRecord.Element.GetValue(originalValueRecord.Property)) == Visibility.Visible ? 1.0 : 0.0);
                        oldOpacities.Add(originalValueRecord.Element, oldOpacity);
                    }
                }
            }

            // now look at the storyboard itself
            foreach (Timeline timeline in layoutStoryboard.Children)
            {
                FrameworkElement target = (FrameworkElement)GetTimelineTarget(control, templateRoot, timeline);

                DependencyProperty property = LayoutPropertyFromTimeline(timeline, true);

                if (target != null && IsVisibilityProperty(property))
                {
                    double oldOpacity;
                    if (!oldOpacities.TryGetValue(target, out oldOpacity))
                    {
                        oldOpacity = ((Visibility)target.GetValue(property) == Visibility.Visible ? 1.0 : 0.0);
                        oldOpacities.Add(target, oldOpacity);
                    }
                }
            }

            return oldOpacities;
        }