我想使用标准淡入效果显示一个窗口。一切都运作良好,但我第一次加载并显示窗口动画淡入不是很顺利。 如果我关闭再显示动画效果会更好。
第一次改善淡入的方法吗?
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);
}
}
}