wpf - RadioButton change background color when checked -
i want override radiobutton
style togglebutton
1
<radiobutton content="point"> <radiobutton.template> <controltemplate> <togglebutton ischecked="{binding ischecked, relativesource={relativesource templatedparent}, mode=twoway}" content="{binding content, relativesource={relativesource templatedparent}, mode=twoway}"/> <controltemplate.triggers> <trigger property="ischecked" value="true"> <setter property="background" value="red"/> </trigger> </controltemplate.triggers> </controltemplate> </radiobutton.template> </radiobutton>
i need change background color of button when it's checked. tried trigger it's not working.
the solution not simple one. issue related fact togglebutton has default background when checked, , 1 has removed, before changing different one.
take @ topic: changing background color of togglebutton when checked
here code should want (used topic reference remove blue highlight on buttons wpf):
<radiobutton content="point"> <radiobutton.template> <controltemplate> <togglebutton ischecked="{binding ischecked, relativesource={relativesource templatedparent}, mode=twoway}" content="{binding content, relativesource={relativesource templatedparent}, mode=twoway}" background="transparent"> <togglebutton.style> <style targettype="togglebutton"> <setter property="overridesdefaultstyle" value="true"/> <setter property="margin" value="5"/> <setter property="template"> <setter.value> <controltemplate targettype="togglebutton"> <border name="border" borderthickness="1" padding="4,2" borderbrush="darkgray" cornerradius="3" background="{templatebinding background}"> <contentpresenter horizontalalignment="center" verticalalignment="center" /> </border> <controltemplate.triggers> <trigger property="ismouseover" value="true"> <setter targetname="border" property="borderbrush" value="black" /> </trigger> <trigger property="ischecked" value="true"> <setter targetname="border" property="background" value="red"/> </trigger> </controltemplate.triggers> </controltemplate> </setter.value> </setter> </style> </togglebutton.style> </togglebutton> </controltemplate> </radiobutton.template> </radiobutton>
Comments
Post a Comment