c# - WPF radio button with Image -


i have create similar picture. if 1 of button clicked others should become darker. lot!

that's need

enter image description here

you can change opacity when radiobutton not checked via style trigger

<radiobutton.style>                         <style targettype="radiobutton">                                 <style.triggers>             <trigger property="ischecked" value="false">                 <setter property="opacity" value="0.5"></setter>             </trigger>         </style.triggers>     </style> </radiobutton.style> 

image inside can created modification of template

<radiobutton.template>     <controltemplate targettype="radiobutton">         <!-- new template -->     </controltemplate> </radiobutton.template> 

default template can found here


my primitive template looks (i have added 3 radiobuttons itemscontrol, 2nd checked)

enter image description here

<stackpanel grid.row="0" grid.column="1">     <stackpanel.resources>         <style x:key="flag" targettype="radiobutton">             <style.triggers>                 <trigger property="ischecked" value="false">                     <setter property="opacity" value="0.5"/>                 </trigger>             </style.triggers>              <setter property="borderthickness" value="2"/>              <setter property="template">                 <setter.value>                     <controltemplate targettype="radiobutton">                         <border borderthickness="{templatebinding borderthickness}"                                 borderbrush="{templatebinding borderbrush}"                                 background="transparent"                                 cornerradius="20">                                                                 <image source="{binding path=content, relativesource={relativesource templatedparent}}"/>                         </border>                     </controltemplate>                 </setter.value>             </setter>         </style>     </stackpanel.resources>      <itemscontrol>         <radiobutton content="../resources/radio.png" style="{staticresource flag}" borderbrush="red" width="40" height="40"/>         <radiobutton content="../resources/radio.png" style="{staticresource flag}" borderbrush="orange" width="40" height="40"/>         <radiobutton content="../resources/radio.png" style="{staticresource flag}" borderbrush="green" width="40" height="40"/>     </itemscontrol> </stackpanel> 

Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -