WPF:如何使" pushlike"复选框? [英] WPF: How to make a "pushlike" checkbox?

查看:153
本文介绍了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>

内容presenter不工作(按钮为空),并单击按钮时,该物业器isChecked不切换。另外,我不知道如何使按钮的外观当推器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.

推荐答案

请问一个<一个href=\"http://msdn.microsoft.com/en-us/library/system.windows.controls.primitives.togglebutton.aspx\">ToggleButton满足您的需求?复选框提炼出来的,所以他们都非常相似。

Would a ToggleButton suit your needs? CheckBox derives from it, and so they are very similar.

这篇关于WPF:如何使&QUOT; pushlike&QUOT;复选框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆