我想弹出一个用户控件,然后在3秒内淡出。我尝试使用以下代码,但在Popup.LoadedEvent和Splash.LoadedEvent的赋值上一直得到错误的参数值。我做错了什么?
Splash s = new Splash();
DoubleAnimation fade = new DoubleAnimation()
{
Duration = new Duration(TimeSpan.FromMilliseconds(3000)),
From = 1.0,
To = 0.0,
RepeatBehavior = new RepeatBehavior(1)
};
fade.Completed += new EventHandler(fade_Completed);
this.popup = new Popup();
this.popup.Child = s;
EventTrigger et = new EventTrigger();
et.RoutedEvent = Popup.LoadedEvent;
Storyboard sb = new Storyboard();
sb.Children.Add(fade);
BeginStoryboard bs = new BeginStoryboard() { Storyboard = sb };
et.Actions.Add(bs);
this.popup.Triggers.Add(et);
this.popup.IsOpen = true;
我也似乎无法找到在哪里/如何设置目标属性。
编辑:通过@Titan2782提供的链接,我已经得到了答案。我已经在下面的回答中发布了它。