如何在wpf中禁用整个视图
我正在开发 MVVM 模式的 WPF 应用程序。
我的应用程序由 2 个模块组成。 第一个模块由一个视图组成。在该视图的底行中,我添加另一个区域,另一个模块在其中加载自己的视图。
问题:每当用户在上部视图中进行任何更改时,下部视图(由另一个模块加载)应该被禁用。
如何实现这一目标?有什么办法可以禁用整个视图吗?
I am working on a WPF application in MVVM pattern.
My application consists of 2 modules.
The first Module consists of a View. In bottom row of that View I am adding another Region in which another module loads its own View.
Issue: whenever user makes any changes in the upper view, the Lower view (loaded by another module) should gets kind of disabled.
How to achieve this? Is there any way to disable whole view?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
XAML UI 是元素的层次结构,通过将 IsEnabled 设置为 false 来禁用任何元素也会禁用其包含的所有子元素。如果您需要启用滚动条或工具提示等功能,则需要更细粒度的 IsEnabled 设置。
XAML UIs are hierarchies of elements and disabling any element by setting IsEnabled to false also disables all of its contained children. If you need to keep things like scrollbars or tooltips enabled you'll need more fine grained IsEnabled settings.
“View.IsEnabled = false”就足够了吗?
Would "View.IsEnabled = false" be enough?
您可以在视图中放置另一个控件,当加载视图模型时,该控件将位于视图其余部分之上。
例如,如果您的视图位于表格的第二行,您还可以放置一个在加载时占据整行的边框,这样用户在它可见时无法执行任何操作。下面的
IsWorking
只是您在开始加载数据或执行任何您不希望用户使用控件时设置的视图模型中的属性。如果您想用它做更多事情(例如添加在工作时播放的动画),您也可以将边框放入您自己的控件或用户控件中。
You could put another control in your view that would lay over top of the rest of it when your view model is loading.
For instance, if your view is in the 2nd row of a table, you could also put a Border that will take up the whole row while loading so the user couldn't do anything while it's visible.
IsWorking
below would just be a property in your view model you set when you start loading data or are doing anything that you don't want the user to use the control.You could also put the Border into your own control or user control if you wanted to do more with it like adding animations that'll play while working.