Programming with .NET - Generalhttp://forums.silverlight.net//17.aspx/1?Programming+with+NET+GeneralGeneral discussions around authoring Silverlight .NET applications.Mon, 01 Jan 0001 00:00:00 -0500175928http://forums.silverlight.net//p/2305/5928.aspx/1?Can+t+Create+Storyboard+from+Scratch+in+CodeCan't Create Storyboard from Scratch in Code <p>SL 1.1, C#</p> <p>I may have screwed something up, but It looks like you can't create and use a storyboard from code.</p> <p><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Storyboard board = new Storyboard();</strong></p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ... (set other storyboard properties)</p> <p><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DoubleAnimation animation = new DoubleAnimation();</strong></p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ... (set animation properties)</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <strong>board.Children.Add(animation);</strong> // &lt;-- can't do this, as there is no add property. Children is a TimeLineGroup with no add function.</p> <p>Did I do something wrong, or is that not yet supported?</p> <p>Thanks.</p> <p>Pete</p> 2007-06-25T01:46:03-04:005937http://forums.silverlight.net//p/2305/5937.aspx/1?Re+Can+t+Create+Storyboard+from+Scratch+in+CodeRe: Can't Create Storyboard from Scratch in Code <p>This doesn't work currently, you can create the appropriate XAML for your storyboard and children and then do a CreateFromXaml, see this thread for more information:</p> <p><a href="http://silverlight.net/forums/t/842.aspx">http://silverlight.net/forums/t/842.aspx</a></p> <p>Another thing I've done is put placeholders in my XAML for the control or the page and then populate the values at run time,&nbsp;for example&nbsp;I would create a storyboard and a doubleanimation child in my XAML, and then set the to and from, and even the target element at run time. </p> 2007-06-25T03:53:00-04:005944http://forums.silverlight.net//p/2305/5944.aspx/1?Re+Re+Can+t+Create+Storyboard+from+Scratch+in+CodeRe: Re: Can't Create Storyboard from Scratch in Code <p>Thanks Bill.</p> <p>I'm glad I wasn't just doing something dumb :)</p> <p>While waiting for a response, I ended up changing the code to use Xaml stubbed animation. If anyone is interested, you can see&nbsp;the results and download the code here in the quick <a class="" href="http://community.irritatedvowel.com/blogs/pete_browns_blog/archive/2007/06/25/Silverlight-1.1-Balloons.aspx" target="_blank"> Silverlight Balloons</a> project.</p> <p>Pete</p> 2007-06-25T05:13:36-04:00