示例#1
0
        public void Show()
        {
            if (Element.Visibility == Visible)
            {
                return;
            }

            var finalPosition = GetAnchorSideOffset();
            var sb            = CreateStoryboard(EntranceAnimation, finalPosition);

            if (sb == null)
            {
                return;
            }

            sb.Completed += (obj, args) =>
            {
                _animating = false;
                ShowCallback?.Invoke();
            };

            Element.Visibility = Visible;
            Element.UpdateLayout();

            UpdateScaling();

            OverlayAnimationUtils.GetCanvasSetter(AnchorSide)?.Invoke(Element, GetHiddenOffset());

            _animating = true;
            sb.Begin();
        }
示例#2
0
        private Storyboard CreateStoryboard(AnimationType type, double to)
        {
            var animation = OverlayAnimationUtils.GetAnimation(type, to);

            if (animation == null)
            {
                return(null);
            }
            Storyboard.SetTargetProperty(animation, new PropertyPath($"(Canvas.{AnchorSide})"));
            Storyboard.SetTarget(animation, Element);

            var sb = new Storyboard();

            sb.Children.Add(animation);
            return(sb);
        }