WPF:如何使“pushlike”复选框? [英] WPF: How to make a "pushlike" checkbox?
本文介绍了WPF:如何使“pushlike”复选框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想创建一个看起来像一个按钮的复选框。我初始的微弱尝试根本不起作用。
I would like to make a CheckBox that looks exactly like a button. My initial feeble attempt doesn't work at all.
<CheckBox x:Name="test">
Testing!
<CheckBox.Template>
<ControlTemplate>
<Button>
<ContentPresenter/>
</Button>
</ControlTemplate>
</CheckBox.Template>
</CheckBox>
ContentPresenter不工作(按钮为空),当按钮被点击时,IsChecked属性不切换。
The ContentPresenter isn't working (the button is empty) and when the button is clicked, the IsChecked property does not toggle. Also, I don't know how to make the button look pushed when IsChecked is true.
推荐答案
如果 ToggleButton 适合您的需要? CheckBox派生自它,因此它们非常相似。
Would a ToggleButton suit your needs? CheckBox derives from it, and so they are very similar.
这篇关于WPF:如何使“pushlike”复选框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文