xaml - How to move a silverlight storyboard into a resourceDictionary? -
i've tried copying , pasting storyboard resource dictionary doesn't work. how can move storyboard animation resource dictionary main xaml file clean , readable possible?
here example of code want move animationresource.xaml
<!-- story board controlling grid animation --> <storyboard x:name="moveball"> <doubleanimation duration="0:0:1" to="200" storyboard.targetproperty="(uielement.rendertransform).(transformgroup.children)[3].(translatetransform.x)" storyboard.targetname="grid" d:isoptimized="true"> <doubleanimation.easingfunction> <backease easingmode="easeinout"/> </doubleanimation.easingfunction> </doubleanimation> </storyboard> <!-- i've left out other default xaml layoutroot grid ---> <grid x:name="grid" horizontalalignment="left" margin="190,180,0,220" width="80" rendertransformorigin="0.5,0.5"> <grid.rendertransform> <transformgroup> <scaletransform/> <skewtransform/> <rotatetransform/> <translatetransform/> </transformgroup> </grid.rendertransform> <ellipse fill="#fff4f4f5" stroke="black"/> </grid>
more detail on isn't working might helpful, @ first glance you'll getting error when trying start storyboard because storyboard.targetname can't resolve (since item name no longer in same file).
a solution set storyboard target (as opposed targetname) in code, perhaps in constructor object containing grid want animate. might like:
storyboard.settarget(app.current.resources["moveball"] storyboard, grid);
you'll have either remove d:isoptomized tag or make sure namespace defined @ top of resource dictionary.
it bears mentioning makes xaml more readable @ cost of making code more complex, might not kind of tradeoff want make.
Comments
Post a Comment