0

我想使用标准淡入效果显示一个窗口。一切正常,但我第一次加载并显示窗口时,动画的淡入淡出不是很流畅。如果我关闭并再次显示它,动画效果会更好

有什么方法可以在第一时间改善淡入淡出吗?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Media.Animation;

namespace Kiosk
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(MainWindow_Loaded);
        }

        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            TimeSpan fadeTime = TimeSpan.FromMilliseconds(250);
            var fadeInAnimation = new DoubleAnimation(1d, fadeTime);
            BeginAnimation(Window.OpacityProperty, fadeInAnimation);
        }
    }
}
4

0 回答 0