简体   繁体   English

如何在Silverlight / WP7中隐藏按钮?

[英]How to hide a button in Silverlight/WP7?

I saw a question here showing to use this: 我在这里看到了一个显示使用此问题的问题:

button.Visibility = Visibility.Hidden;

but I only have Collapsed or Visible, and Collapsed removes the button which changes the layout of the controls which I don't want. 但我只有“合拢”或“可见”,并且“合拢”会删除按钮,该按钮会更改不需要的控件的布局。

Any ideas on how to solve this? 关于如何解决这个问题的任何想法?

Apparently you are on the Silverlight framework which doesnT have the Hidden option. 显然,您使用的是Silverlight框架,该框架没有“ Hidden选项。

Silverlight does not support the Hidden Visibility state. Silverlight不支持“隐藏可见性”状态。

You can see the available members in both .Net framework and Silverlight in the reference . 您可以在参考资料中看到.Net framework和Silverlight 中的可用成员。 (use the dropdown on top of the page to switch between different platforms) (使用页面顶部的下拉菜单在不同平台之间切换)

A crooked solution to your problem could be setting the opacity of the UI element to 0 but this approach is known to have performance drawbacks. 歪曲您问题的解决方案可能是将UI元素的opacity设置为0但这种方法已知会带来性能缺陷。

Another solution if you don't want to resort to changing the Opacity would be encapsulate the button within a Grid and set the Grid height property to fixed size corresponding to the button height. 如果您不想更改不透明度,则另一个解决方案是将按钮封装在Grid中,然后将Grid height属性设置为与按钮高度相对应的固定大小。 Now you can Collapse the button without other controls rearranging themselves. 现在,您可以折叠按钮,而无需其他控件重新排列自己。

Cheers, Anders 干杯,安德斯

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM