Tutorial :WPF exception running animation in another class



Question:

I can run an animation from the main window class but if I try to run the same code from another class in the same namespace I receive an exception in the storyboard begin function
this is the exception:

No applicable name scope exists to resolve the name 'DefaultGroup'.

this is how I set the storyboard target and property

Storyboard.SetTargetName(r3d,"DefaultGroup");  Storyboard.SetTargetProperty(r3d, new PropertyPath("(Visual3D.Transform).(Transform3DGroup.Children)[2].(RotateTransform3D.Rotation)"));  

How can I fix this?
Thanks
Walther


Solution:1

--otherUserControl.cs

StackPanel defaultGroup;  

--MainWindow.cs

this.RegisterName(otherUserControl.defaultGroup.Name, otherUserControl.defaultGroup); // RegisterName    Storyboard.SetTargetName(r3d,"defaultGroup");  Storyboard.SetTargetProperty(r3d, new PropertyPath("(Visual3D.Transform).(Transform3DGroup.Children)[2].(RotateTransform3D.Rotation)"));  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »