Reputation: 1505
I have this code inside a window method (AddServer is a user control)
addServer = new AddServer();
addServer.Height = 300;
addServer.Width = 570;
this.RegisterName("addServerPanel", addServer);
Main.Children.Add(addServer);
// 252, 248, 26, 0
addServer.Margin = new Thickness(252, 550, 26, 0);
ThicknessAnimation thicknessAnimation = new ThicknessAnimation();
thicknessAnimation.From = new Thickness(252, 550, 26, 0);
thicknessAnimation.To = new Thickness(252, 248, 26, 0);
thicknessAnimation.Duration = new Duration(TimeSpan.FromSeconds(5));
Storyboard.SetTargetName(thicknessAnimation, "addServerPanel");
Storyboard.SetTargetProperty(thicknessAnimation, new PropertyPath(MarginProperty));
Storyboard storyboard = new Storyboard();
storyboard.Children.Add(thicknessAnimation);
storyboard.Begin();
And I get an InvalidOperationException when the storyboard starts to begin. It is saying that he can't resolve the name addServerPanel
so I think the window has not registered the name of the usercontrol. How could I fix this?
Upvotes: 1
Views: 123