c# - wpf checkbox label as button -
in wpf label in checkbox behave button, when toggle checkbox on, label change button, , when toggle checkbox off, button go change label.
here have far
<checkbox margin="2,0,2,0" ischecked="{binding issteps}" horizontalalignment="stretch" verticalalignment="bottom" height="32" focusvisualstyle="{x:null}" style="{staticresource slidercheckboxstyle}"> <checkbox.content> <textblock text="steps" foreground="#ffffffff" fontfamily="lucida sans" fontsize="8" fontweight="bold"/> </checkbox.content> </checkbox>
in checkbox.content, create stackpanel both textblock , button. then, can bind textblock.visibilty , button.visibilty "issteps" triggers , setters.
<checkbox margin="2,0,2,0" ischecked="{binding issteps}" horizontalalignment="stretch" verticalalignment="bottom" height="32" focusvisualstyle="{x:null}" style="{staticresource slidercheckboxstyle}"> <checkbox.content> <stackpanel> <textblock text="steps" foreground="#ffffffff" fontfamily="lucida sans" fontsize="8" fontweight="bold"> <textblock.style> <style targettype="textblock"> <style.triggers> <datatrigger binding="{binding issteps}" value="true"> <setter property="visibility" value="collapsed"> </datatrigger> </style.triggers> </style> <textblock.style> </textblock> <button> <button.style> <style targettype="button"> <style.triggers> <datatrigger binding="{binding issteps}" value="false"> <setter property="visibility" value="collapsed"> </datatrigger> </style.triggers> </style> <button.style> </button> </stackpanel> </checkbox.content> </checkbox>
now visibility property depends on issteps datacontext object, when 1 appears , other 1 disappears.
Comments
Post a Comment