How to make rotation in XAML of one element by clicking on another one? -
i have such code (cut part needed; code used usercontrol):
<grid> <image x:name="im" horizontalalignment="left" height="120" width="120"> <image.rendertransform> <rotatetransform angle="0" centerx="60" centery="60" /> </image.rendertransform> </image> <button x:name="br" content="right" width="55"> <button.triggers> <eventtrigger routedevent="mouseup"> <beginstoryboard> <storyboard> <doubleanimation storyboard.targetname="im" storyboard.targetproperty="rendertransform.angle" by="90" duration="0:0:1" /> </storyboard> </beginstoryboard> </eventtrigger> </button.triggers> </button> </grid>
i'd rotate image ("im") 90 degrees clicking "br" button. code doesn't work. if utilize code:
<grid> <image x:name="im" horizontalalignment="left" height="120" width="120"> <image.rendertransform> <rotatetransform angle="0" centerx="60" centery="60" /> </image.rendertransform> <image.triggers> <eventtrigger routedevent="mouseup"> <beginstoryboard> <storyboard> <doubleanimation storyboard.targetname="im" storyboard.targetproperty="rendertransform.angle" by="90" duration="0:0:1" /> </storyboard> </beginstoryboard> </eventtrigger> </image.triggers> </image> <button x:name="br" content="right" width="55"> </button> </grid>
rotation works (image rotating clicking on it). what's wrong first one?
did tried button.click routed event instead of mouseup. reason mouseup not working button explained here: wpf event not bubbling.
the code provided work on right button click of mouse. on left button click of mouse, click event swallowing mouse events.
i tried below code , seems work. have used dummy image source.
<grid> <grid.rowdefinitions> <rowdefinition></rowdefinition> <rowdefinition></rowdefinition> </grid.rowdefinitions> <image x:name="im" horizontalalignment="left" height="120" width="120" source="..\images\info.png"> <image.rendertransform> <rotatetransform angle="0" centerx="60" centery="60" /> </image.rendertransform> </image> <button x:name="br" grid.row="1" content="right" width="55"> <button.triggers> <eventtrigger routedevent="button.click"> <beginstoryboard> <storyboard> <doubleanimation storyboard.targetname="im" storyboard.targetproperty="rendertransform.angle" by="90" duration="0:0:1" /> </storyboard> </beginstoryboard> </eventtrigger> </button.triggers> </button> </grid>
let me know in case need more information.
xaml
No comments:
Post a Comment