Skip to main content
Home Forums Silverlight Programming Programming with .NET - General dynamically insert a storyboard?
2 replies. Latest Post by cdubone on May 5, 2008.
(0)
cdubone
Member
187 points
224 Posts
05-05-2008 4:59 AM |
Is there a way to dynamically change the content of a storyboard (double animations and such)? What I mean is I would like to have:<Storyboard x:Name="Animation"> </Storyboard>hard coded into my application, and then on a button click insert some DoubleAnimationUsingKeyFrames. I'd also like to clear the content in order to insert more. Is this possible?
mchlsync
Star
14606 points
2,730 Posts
05-05-2008 9:52 AM |
What about creating the entire storyboard object dynamically?
For example:
string sbdef = @"<Storyboard><DoubleAnimationUsingKeyFrames BeginTime='00:00:00' Storyboard.TargetName='text1' Storyboard.TargetProperty='(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)'><SplineDoubleKeyFrame KeyTime='00:00:00.5000000' Value='{0}'/></DoubleAnimationUsingKeyFrames></Storyboard>";double angle=0;void Clicked(object sender, EventArgs e){angle +=90;Storyboard sb= (Storyboard) XamlReader.Load(String.Format(sbdef, angle));this.Resources.Add (sb);sb.Begin();}
Ref: http://silverlight.net/forums/t/842.aspx
05-05-2008 6:01 PM |
Cool, thanks! I'm actually doing something very similar to this already. The difference is that I'm unpacking it from a zip (along with images and a media file). It turns out the problem I was having wasn't being caused by this as I thought, it was something totally different.
Thanks for the help!