c# - WPF radio button with Image -
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)
<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
Post a Comment