i new xaml have managed make clickable map using path elements , created style them :
<style x:key="selectablearea" targettype="path"> <setter property="stroke" value="#ff4e4e4e" /> <setter property="strokethickness" value="1" /> <setter property = "fill" value="#ff4da3ae" /> <style.triggers> <trigger property = "ismouseover" value = "true"> <setter property = "fill" value="#ff52c7b1" /> <setter property="cursor" value="hand"/> </trigger> </style.triggers> </style>
i have textblock need fill name of hovered area (or path)
right have done :
<path tag="area's name" mouseenter="areamouseenter" mouseleave="areamouseleave" style="{staticresource selectablearea}" data="m427.8,153.7l418.7 ..../>
in methode areamouseenter update textblock gets filled tag value of hovered path , in areamouseleave set default value.
void areamouseenter(object sender, system.windows.input.mouseeventargs e) { if(sender path && ((path)sender).tooltip != null) { mytextbox.text = ((path)sender).tooltip.tostring(); } }
this isn't because have lot of path elements (87) , repeating mouseenter="areamouseenter" mouseleave="areamouseleave"
in every 1 of them doesn't produce clean code (witch important application).
how solve ?
i hope clear. if have questions dont hesitate ask.
i trying 2 days understand how triggers , behaviors work because thought solution
what looking simple after :
<eventsetter event="mouseenter" handler="areamouseenter"/> <eventsetter event="mouseleave" handler="areamouseleave"/>
Comments
Post a Comment