wpf 如何创建一个完全不可见的按钮?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14423947/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I create a completely invisible button?
提问by It'sNotALie.
I'm trying to create a WPF button, that is completely invisible, but still has an onclick or click event, without resorting to something like MouseDown and check the keyeventargs, etc.
我正在尝试创建一个 WPF 按钮,它是完全不可见的,但仍然具有 onclick 或 click 事件,而无需求助于 MouseDown 之类的东西并检查 keyeventargs 等。
I have tried setting the button's visibility to Collapsed or Hidden, which also makes the button unclickable, and therefore useless for my purposes.
我曾尝试将按钮的可见性设置为折叠或隐藏,这也会使按钮无法点击,因此对我的目的毫无用处。
Any more ideas?
还有更多想法吗?
回答by Abdusalam Ben Haj
Try this :
尝试这个 :
<Button Opacity="0" />
回答by Rachel Gallen
just make a button and set
只需制作一个按钮并设置
button.Visibility = Visibility.Hidden;
or
或者
button.Visibility = Visibility.Collapsed;

