Пример #1
0
        private void SlideNext(object nextContent, double durationSecond)
        {
            LblAnima.Foreground = LblContent.Foreground;
            LblAnima.Opacity    = 1;
            LblContent.Margin   = new Thickness(0, 0, 0, 0);
            LblAnima.Content    = nextContent;
            var thicknessAnima1 = new ThicknessAnimation()
            {
                From     = new Thickness(0, ActualHeight * 2, 0, 0),
                To       = new Thickness(0),
                Duration = TimeSpan.FromSeconds(durationSecond),
            };
            var thicknessAnima2 = new ThicknessAnimation()
            {
                From     = new Thickness(0),
                To       = new Thickness(0, -ActualHeight * 2, 0, 0),
                Duration = TimeSpan.FromSeconds(durationSecond),
            };

            thicknessAnima2.Completed += delegate
            {
                LblAnima.BeginAnimation(MarginProperty, null);
                LblContent.BeginAnimation(MarginProperty, null);
                Content           = nextContent;
                LblContent.Margin = new Thickness(0);
                LblAnima.Opacity  = 0;
            };
            LblAnima.BeginAnimation(MarginProperty, thicknessAnima1);
            LblContent.BeginAnimation(MarginProperty, thicknessAnima2);
        }
Пример #2
0
        private void FadeNext(object nextContent, double durationSecond)
        {
            LblAnima.Foreground = LblContent.Foreground;
            LblContent.Margin   = new Thickness(0, 0, 0, 0);
            LblAnima.Content    = nextContent;
            var doubleAnima1 = new DoubleAnimation()
            {
                From     = 0,
                To       = 1,
                Duration = TimeSpan.FromSeconds(durationSecond),
            };
            var doubleAnima2 = new DoubleAnimation()
            {
                From     = 1,
                To       = 0,
                Duration = TimeSpan.FromSeconds(durationSecond),
            };

            doubleAnima2.Completed += delegate
            {
                LblAnima.BeginAnimation(OpacityProperty, null);
                LblContent.BeginAnimation(OpacityProperty, null);
                Content            = nextContent;
                LblAnima.Opacity   = 0;
                LblContent.Opacity = 1;
            };
            LblAnima.BeginAnimation(OpacityProperty, doubleAnima1);
            LblContent.BeginAnimation(OpacityProperty, doubleAnima2);
        }