xaml - Change Fill Property of a path on pressed event -
i have border element contains path element , when border tapped want change fill property of path color.
i have searched answer seems use control templates , styles (generally buttons) kind of behaviour. there way change color without using control templates , styles?
my code far follows,
<border> <canvas width="32" height="32" canvas.left="0" canvas.top="0"> <path x:name="myicon" width="30.5" height="30.5" canvas.left="0.75" canvas.top="0.750008" stretch="fill" strokethickness="3" strokelinejoin="round" stroke="{staticresource phoneforegroundbrush}" data="f1 m 15.9707,2.25001l 19.167,12.7919l 29.75,12.8197l 21.2578,19.1225l 24.4292,29.75l 16.0879,23.2829l 7.51911,29.6986l 10.831,19.2255l 2.25,12.7983l 12.7665,12.8177l 15.9707,2.25001 z "/> </canvas> <i:interaction.behaviors> <core:eventtriggerbehavior eventname="tapped"> <core:invokecommandaction command="{binding changecommand}"/> </core:eventtriggerbehavior> </i:interaction.behaviors> <visualstatemanager.visualstategroups> <visualstategroup x:name="commonstates"> <visualstate x:name="normal" /> <visualstate x:name="pressed"> <storyboard> <coloranimation storyboard.targetname="myicon" storyboard.targetproperty="(path.fill).(solidcolorbrush.color)" to="#ffff0000" duration="0:0:0.5" /> </storyboard> </visualstate> </visualstategroup> </visualstatemanager.visualstategroups> </border>
thanks helps in advance.
in 'pressed' visualstate
, animating color
property of solidcolorbrush
assigned fill
property of 'myicon' path
. however, haven't assigned solidcolorbrush
object fill
property of 'myicon'. hence if try go 'pressed' state, won't able find solidcolorbrush
reference , throw exception. simplest solution assign fill="transparent"
in 'myicon' path
.
i'm assuming have put border
inside control
, , calling visualstatemanager.gotostate
in appropriate places.
Comments
Post a Comment