views:

213

answers:

0

This our method for animating a selected ModelVisual3D in the viewport. We try to animate this specific model when clicking button2, but when we do, nothing happens.

Any hints or suggestions on what we should do?

private void button2_Click(object sender, RoutedEventArgs e)
{            
  //Create a storyboard for the animations.
  Storyboard storybrd = new Storyboard();

  //Define a DoubleAnimation to lift the table.
  DoubleAnimation animaDouble = new DoubleAnimation();
  animaDouble.From = 0;
  animaDouble.To = 90;

  //mv3dSelectedInMainVP is a selected ModelVisual3D in the viewport "vpWorkArea"
  vpWorkArea.RegisterName("modelToBeAnimated", mv3dSelectedInMainVP);

  Storyboard.SetTargetName(animaDouble, "modelToBeAnimated");
  Storyboard.SetTargetProperty(animaDouble,
      new PropertyPath(AxisAngleRotation3D.AngleProperty));

  vpWorkArea.Resources.Add("unique", storybrd);

  storybrd.Children.Add(animaDouble);
  storybrd.Begin();            
}