如何在C#中创建一个不可见但可单击的按钮

时间:2021-09-02 08:12:12

I would like to be able to have a button that is not visible, but able to trigger a click event when clicked.

我希望能够有一个不可见的按钮,但能够在单击时触发单击事件。

I'm looking at this page MSDN: System.windows.visibilty and it seems that buttons can have three visibility states. Visible, Hidden and Collapsed. When the button is Hidden or Collapsed, I can't see it (which is good) but I can't click it (which is bad).

我正在看这个页面MSDN:System.windows.visibilty,似乎按钮可以有三个可见性状态。可见,隐藏和崩溃。当按钮被隐藏或折叠时,我看不到它(这是好的)但是我无法点击它(这是不好的)。

Does anyone have a way that I can make clickable invisible element in my XAML file?

有没有人可以在我的XAML文件中制作可点击的不可见元素?

2 个解决方案

#1


30  

Try setting the Button's Opacity...

尝试设置Button的不透明度......

<Button Opacity="0" />

#2


2  

Can't you use the Opacity property?

你不能使用Opacity属性吗?

#1


30  

Try setting the Button's Opacity...

尝试设置Button的不透明度......

<Button Opacity="0" />

#2


2  

Can't you use the Opacity property?

你不能使用Opacity属性吗?