I'm trying to popup a user control and then fade it out over 3 seconds. I'm trying to use the following code but I keep getting incorrect parameter value on the assignment of Popup.LoadedEvent as well as Splash.LoadedEvent. What am I doing wrong?
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;
I also cant seem to figure out where/how to set the target property.
Edit: I was able to get the answer using the link @Titan2782 provided. I've posted it in an answer below.