I need somehow pass double fromH, double toH, UIElement control to the AnimateH method within of sb.Completed but I got the error
The name ‘toW’ does not exist in the current context issue
and etc..
How do i can fix it?
Thank you!
void AnimateTop(double from, double to, double fromH, double toH, UIElement control)
{
Debug.WriteLine("EFM - AnimateTop - from: " + from.ToString() + " to: " + to.ToString());
Storyboard sb = new Storyboard();
DoubleAnimation da = new DoubleAnimation();
da.From = from;
da.To = to;
da.Duration = new Duration(TimeSpan.FromSeconds(1));
sb.Children.Add(da);
Storyboard.SetTargetProperty(da, new PropertyPath("(Canvas.Top)"));
Storyboard.SetTarget(da, control);
sb.Completed += (w, r) =>
{
AnimateH(fromW, toW, control); // Here is the error
control.UpdateLayout();
};
sb.Begin();
}
You’re using
toWbut it’s not declared anywhereor passed as parameter
If it’s a value that comes from another place, you should passed as a parameter. If it’s a value created from some method there, you should declare the type and get its value
before using it.