I'm trying to create a storyboard completely in C#, no XAML at all but I'm having trouble with (SetTarget and SetTargetProperty) .. here's my code
I'm just animating my UserControl when the user navigates to it, it goes from 0 opacity to 100 and from 900 TransformX to 0 in .5 seconds.
I would really appreciate any help with setting these two parameters, been at it all day with no luck!
public void Designer()
{
Control_ = new UserControl();
Control_.HorizontalAlignment = HorizontalAlignment.Stretch;
Control_.VerticalAlignment = VerticalAlignment.Stretch;
Control_.Name = "Control_";
this.AddChild(Control_);
CreateStoryboard();
}
public void CreateStoryboard()
{
fadeinBoard = new Storyboard();
Duration duration = new Duration(TimeSpan.FromMilliseconds(5));
fadeinBoard.Duration = duration;
DoubleAnimationUsingKeyFrames animOpacity = new DoubleAnimationUsingKeyFrames();
DoubleAnimationUsingKeyFrames animTransform = new DoubleAnimationUsingKeyFrames();
animOpacity.Duration = duration;
animTransform.Duration = duration;
//Transform Function
KeyTime ktime1 = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(.5));
PowerEase pow = new PowerEase();
pow.Power = 5;
pow.EasingMode = EasingMode.EaseOut;
EasingDoubleKeyFrame keyFrame1 = new EasingDoubleKeyFrame(0, ktime1, pow);
//Opacity Function
KeyTime ktime2 = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(.5));
ExponentialEase expo = new ExponentialEase();
expo.Exponent = 3;
expo.EasingMode = EasingMode.EaseOut;
EasingDoubleKeyFrame keyFrame2 = new EasingDoubleKeyFrame(1, ktime2, expo);
animOpacity.KeyFrames.Add(keyFrame1);
animTransform.KeyFrames.Add(keyFrame2);
// MY PROBLEM IS HERE
Storyboard.SetTarget(???, ???);
Storyboard.SetTarget(???, ???);
Storyboard.SetTargetProperty(???, ???);
Storyboard.SetTargetProperty(???, ???)));
fadeinBoard.Children.Add(animOpacity);
fadeinBoard.Children.Add(animTransform);
Control_.Resources.Add("fader", fadeinBoard);
}