c# - Storyboard targetting GridLength for WP8 -
i want make storyboard rowdefinition changing height, , found this me. problem when want create class gridlengthanimation, cannot make animationtimeline. because windows phone 8 not support this?
in case there work around making storyboard rowdefinition?
easiest way may put grids rows, , animate height-property this.
here xaml:
<grid x:name="layoutroot"> <grid.rowdefinitions> <rowdefinition height="auto"/> <rowdefinition height="auto"/> <rowdefinition height="auto"/> <rowdefinition height="auto"/> </grid.rowdefinitions> <grid background="aliceblue" grid.row="0" height="100" tap="grid_tap" cachemode="bitmapcache" /> <grid background="antiquewhite" grid.row="1" height="100" tap="grid_tap" cachemode="bitmapcache" /> <grid background="aqua" grid.row="2" height="100" tap="grid_tap" cachemode="bitmapcache" /> <grid background="aquamarine" grid.row="3" height="100" tap="grid_tap" cachemode="bitmapcache" /> </grid>
and cs:
private void animateheight(grid grid) { double newheight = grid.actualheight == 100 ? 300 : 100; //select height want animate storyboard story = new storyboard(); doubleanimation animation = new doubleanimation(); animation.to = newheight; animation.duration = timespan.fromseconds(0.5); storyboard.settarget(animation, grid); storyboard.settargetproperty(animation, new propertypath(grid.heightproperty)); story.children.add(animation); story.begin(); } private void grid_tap(object sender, system.windows.input.gestureeventargs e) { grid grid = sender grid; //select grid tapped animateheight(grid); }
notice putted cachemode bitmapcache of grids. that's not necessary, gives more fluent animation, because static grids won't redrawed again in each frame.
Comments
Post a Comment