xaml - How can I move an EllipsePath using animation in WPF? -
i want make slider button using wpf. have code create circle , move when clicked.
<window x:class="wpfapplication1.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" title="mainwindow" height="350" width="525"> <grid> <border background="lightgray" margin="167,63,224,190" cornerradius="20,20,20,20" height="40" width="80"> <path fill="red"> <path.data> <ellipsegeometry center="20,20" radiusx="20" radiusy="20"/> </path.data> <path.effect> <dropshadoweffect direction="270" shadowdepth="2" color="gray"></dropshadoweffect> </path.effect> <path.triggers> <eventtrigger routedevent="border.mousedown"> <eventtrigger.actions> <beginstoryboard> <storyboard> <pointanimation storyboard.targetproperty="center" duration="0:0:0.3" from="20,20" to="60,20"></pointanimation> </storyboard> </beginstoryboard> </eventtrigger.actions> </eventtrigger> </path.triggers> </path> </border> </grid>
it okey shows when program started. throws exception when clicked on it. error system.invalidoperationexception
. how can fix problem?
perhaps closer looking do?
<window x:class="mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:wpfapplication1" mc:ignorable="d" title="mainwindow" height="350" width="525"> <grid> <border background="lightgray" margin="167,63,224,190" cornerradius="20,20,20,20" height="40" width="80"> <canvas> <ellipse fill="red" width="40" height="40" canvas.left="0" canvas.top="0"> <ellipse.effect> <dropshadoweffect direction="270" shadowdepth="2" color="gray"></dropshadoweffect> </ellipse.effect> <ellipse.triggers> <eventtrigger routedevent="border.mousedown"> <eventtrigger.actions> <beginstoryboard> <storyboard> <doubleanimation storyboard.targetproperty="(canvas.left)" duration="0:0:0.3" from="0" to="40" /> </storyboard> </beginstoryboard> </eventtrigger.actions> </eventtrigger> </ellipse.triggers> </ellipse> </canvas> </border> </grid>
Comments
Post a Comment