如何禁用XAML Metro应用网格(图)?(How to disable a Grid (Pane

2019-08-07 09:46发布

我想效仿的模态对话框中的XAML Metro应用。

所以我打算从其中一个会伪装成一个模式对话框中脱颖而出.IsEnabled =假上的所有控件。

显然的IsEnabled不是在电网未面板不是FrameworkElement的。 如何禁用它不会使用户控制出来的吗?

我想辛诺夫斯基切割成许多角落,整个事情,现在更像是一个埃舍尔楼梯。 我失去了我的信仰。 请帮忙

Answer 1:

Sorry, I am a little late to the party...

Here is how I created a modal popup - I used a popup dialog where the top and bottom portions are transparent so that anything behind it will show through. When the popup is opened, I set its size to cover the entire screen.

The top and bottom portions of the popup also are set to autosize (height = *), so that they fill up the entire top and bottom of the screen. This prevents any input from going into the grid underneath.

Here is a screen shot of my popup in Visual Studio:

The popup is a grid with 5 rows, 3 for the dialog itself and 2 for the transparent top and bottom.

Here is how the popup looks in my app. Obviously the grid shows through the transparent top and bottom. Since the popup fills the entire screen, any input (keyboard or mouse) goes to it rather than the grid underneath, making the popup act like a modal dialog.

Be warned though that with this strategy, you have to handle these events:

  • Screen resizes (full screen, snapped view, filled view) - you need to resize the popup to fit within each of the view states
  • Screen rotation - again, you have to handle resizing here
  • Keyboard popup - you need to shift the popup up so that the onscreen keyboard does not interfere with it.


Answer 2:

设置IsHitTestVisible = false的背景内容。

此外,您可以将焦点设置的东西在你的模式层根并设置TabNavigationCycle的模式层根,以确保用户无法选项卡/ Shift + Tab出来。 另外,还要确保模态层全部命中测试固体-例如Transparent或具有其他一些填充,使用户无法通过点击它。

另外,还要确保没有Popups显示,而你的模式层是可见的。



Answer 3:

不幸的是,似乎没有人知道(除Skakun先生是谁给了错误的答案,从来没有费心去修改它)。

因此,我的解决方案(最简单的)是使元素隐藏的问题 - 我无法找到任何其他方式来“禁用”的网格。

如果我想正确地禁用它,我会写一个递归函数找到在网格中孩子们都FrameworkElements和设置的IsEnabled =虽然假。



文章来源: How to disable a Grid (Panel) in XAML Metro app?