1
は私がThicknessAnimation InvalidOperationExceptionが
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();
(からaddServerがユーザーコントロールである)ウィンドウメソッド内でこのコードを持っており、ストーリーボードを開始し始めたとき、私はInvalidOperationExceptionがを取得します。彼は名前addServerPanel
を解決できないと言っているので、私はウィンドウがusercontrolの名前を登録していないと思う。どうすればこの問題を解決できますか?
に直接設定する
SetTarget
メソッドを使用することができますが、[設定された目標](https://msdn.microsoft.com/en-us/にしようとしましたライブラリ/ windows/apps/windows.ui.xaml.media.animation.storyboard.settarget)を 'addServer'に直接追加するのですか? – dkozlありがとう!それはうまくいった。これを回答として追加して、それを改善します。 – chris579