c# - how to move UI element with storyboard? -


i've worked opacity property in storyboard cant figure out how move ui element grid stackpanel button ..... in c#? (i writing storyboard in c# not in xaml )

well, depends on actual layout: want animate button in grid or in canvas (could animate margin property or canvas.left attached property, respectively)? want animate property or transform (the latter animate rendertransform - translatetransform). use rendertransform if still want refer "old" position.

one simple way is:

<window   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">   <grid>     <grid.triggers>         <eventtrigger routedevent="grid.loaded">             <beginstoryboard>                 <storyboard repeatbehavior="forever">                     <doubleanimation storyboard.targetname="mybutton"                         storyboard.targetproperty="(canvas.left)" from="1" to="350"                         duration="0:0:10" begintime="0:0:0"/>                 </storyboard>             </beginstoryboard>         </eventtrigger>     </grid.triggers>     <canvas x:name="mycanvas" background="yellow">        <button x:name="mybutton" width="100" height="30" canvas.left="100" canvas.top="100" />     </canvas>   </grid> </window> 

Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -