‘m a newbie and I’m playing around with Windows Presentation Foundation using framework 3.5 , and i just got started with story boards and animations. I tried creating instances of Canvas and animating the canvas using instances of Story Board + animations, and it was fun. Now I wanna come up with some organized way with which I can define many animations easily and to use them (defining the object instances inside code is too tedious).
I heard of using XAML to do that, and I’ve seen some examples in CodeProject.com, but they all seem to be defining UserControls with the storyboards inside them. That seems too hard for me, what I wanna do is just define the storyboard tags and the animation tags inside the storyboard tags, as a Class, is it possible to do it this way? What I mean is, is it possible to define a class (not a User Control) in XAML, and then call its variables like “StoryBoard1” or “StoryBoard2” whenever I wanna use that particular animation? How should I go about implementing it?
You can define
Storyboardsetc in theWindow.Resourcesif you want reusable animations.These are known as
ResourcesnotClassesExample:
To access these resources from code behind you can use
FindResource