共有のストーリーボードを使用してアニメートしている3Dキューブがあります。アニメーションコードは、コンボボックスのselectionChangedイベント内にあり、実行中のアニメーションが次の開始前に停止されることを確認することを意図しています。それはそのように動作していない!WPF - アニメーション化されたStoryBoardを停止できません。IsControllableが機能しません。
これは非常に乱雑なコードですが、私はまだ私のストーリーボードが私に.begin(this、true)を呼び出しているので、なぜそれに応答しないのか分かりません。
誰かが私がストーリーボードを止められない理由を教えてもらえますか?私はまだ、私はあなたが始める方法にではなく、これよりもCBOに渡す必要が信じている危険な'System.Windows.Media.Animation Warning: 6 : Unable to perform action because the specified Storyboard was never applied to this object for interactive control.; Action='Stop';'
メッセージ
Storyboard sb = new Storyboard();
DoubleAnimation forward90 = new DoubleAnimation(0,90,TimeSpan.FromMilliseconds(2000));
DoubleAnimation back90 = new DoubleAnimation(0,-90, TimeSpan.FromMilliseconds(2000));
private void cbo_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
forward90.BeginTime = TimeSpan.Zero;
back90.BeginTime = TimeSpan.Zero;
NameScope.SetNameScope(this, new NameScope());
RegisterName(this.Name, this);
sb.Stop(this);
sb.Remove(this);
sb.Children.Clear();
sb.AccelerationRatio = 0;
sb.DecelerationRatio = 1;
sb.RepeatBehavior = RepeatBehavior.Forever;
int i = cbo.SelectedIndex;
Orientation o = (Orientation)i;
ViewModel vm = this.DataContext as ViewModel;
if(vm !=null)vm.Orient = o;
switch (o)
{
case Orientation.Front0:
break;
case Orientation.Front90:
sb.Children.Add(forward90);
Storyboard.SetTarget(forward90, cube2);
Storyboard.SetTargetProperty(forward90, new PropertyPath(CubeControl.CubeControl.XRotationProperty));
sb.Begin(this, true);
break;
case Orientation.Right0:
sb.Children.Add(back90);
Storyboard.SetTarget(back90, cube2);
Storyboard.SetTargetProperty(back90, new PropertyPath(CubeControl.CubeControl.YRotationProperty));
sb.Begin(this, true);
break;
case Orientation.Right90:
back90.BeginTime = TimeSpan.FromMilliseconds(2000);
sb.Children.Add(forward90);
sb.Children.Add(back90);
Storyboard.SetTarget(back90, cube2);
Storyboard.SetTarget(forward90, cube2);
Storyboard.SetTargetProperty(forward90, new PropertyPath(CubeControl.CubeControl.YRotationProperty));
Storyboard.SetTargetProperty(back90, new PropertyPath(CubeControl.CubeControl.ZRotationProperty));
sb.Begin(this, true);
break;
case Orientation.Top0:
sb.Children.Add(back90);
Storyboard.SetTarget(back90, cube2);
Storyboard.SetTargetProperty(back90, new PropertyPath(CubeControl.CubeControl.ZRotationProperty));
sb.Begin(this, true);
break;
case Orientation.Top90:
back90.BeginTime = TimeSpan.FromMilliseconds(2000);
sb.Children.Add(forward90);
sb.Children.Add(back90);
Storyboard.SetTarget(forward90, cube2);
Storyboard.SetTarget(back90, cube2);
Storyboard.SetTargetProperty(forward90, new PropertyPath(CubeControl.CubeControl.XRotationProperty));
Storyboard.SetTargetProperty(back90, new PropertyPath(CubeControl.CubeControl.ZRotationProperty));
sb.Begin(this, true);
break;
default:
break;
}
}
}
いいえ、サイコロです。ちょうど試みたが、それはまだ動作しませんでした。まぁ! – Stimul8d
ちょうど古いチケットに追いついて、あなたが本当に正しいとわかった...私は、NameScopeとRegisterNameのものを削除する必要がありました。 – Stimul8d