c# - How can i use isPressed in Label? -



c# - How can i use isPressed in Label? -

this part of code, search on google no 1 know mean.

<label horizontalcontentalignment="center" verticalcontentalignment="center" width="30" height="30" content="" fontfamily="fontawesome" horizontalalignment="right" verticalalignment="center"> <label.style> <style targettype="{x:type label}"> <style.triggers> <trigger property="label.ismouseover" value="true"> <setter property="label.background" value="yellow" /> </trigger> </style.triggers> </style> </label.style> </label>

you can seek using eventtrigger in case. if's of course of study longer it's simplest approach using pure standard xaml (not custom):

<label horizontalcontentalignment="center" verticalcontentalignment="center" width="30" height="30" content="clgt?" fontfamily="fontawesome" horizontalalignment="right" verticalalignment="center"> <label.style> <style targettype="{x:type label}"> <style.triggers> <eventtrigger routedevent="mouseleftbuttondown"> <beginstoryboard> <storyboard> <coloranimation to="yellow" duration="0" storyboard.targetproperty="background.color"/> </storyboard> </beginstoryboard> </eventtrigger> <eventtrigger routedevent="mouseleftbuttonup"> <beginstoryboard> <storyboard> <coloranimation to="transparent" duration="0" storyboard.targetproperty="background.color"/> </storyboard> </beginstoryboard> </eventtrigger> </style.triggers> </style> </label.style> </label>

it's improve utilize removestoryboard action when mouseleftbuttonup this:

<style.triggers> <eventtrigger routedevent="mouseleftbuttondown"> <beginstoryboard name="bg"> <storyboard> <coloranimation to="yellow" duration="0" storyboard.targetproperty="background.color"/> </storyboard> </beginstoryboard> </eventtrigger> <eventtrigger routedevent="mouseleftbuttonup"> <removestoryboard beginstoryboardname="bg"/> </eventtrigger> </style.triggers>

c# wpf

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -