我是MVVM世界的新手。我对子窗口有疑问,需要一些解释。我有一些数据收集,并将其显示在主窗口的 datagrid 中。我想从集合中选择一个项目,并想在模态窗口,对话框或弹出中显示该数据。我想编辑该数据,这些更改应反射(reflect)在主窗口的datagrid中。
谁能告诉我模态窗口,对话框和中弹出的最佳选择。我正在使用MVVM Light Toolkit。
最佳答案
我认为模式窗口和非模式窗口之间的选择仅取决于您要实现的UI体验。如果由于某种原因无法同时对网格项目上的其他操作进行行项目的更新,则需要模态项目。
如此处所述Dialog boxes overview
A modal dialog box is displayed by a function when the function needs additional data from a user to continue. Because the function depends on the modal dialog box to gather data, the modal dialog box also prevents a user from activating other windows in the application while it remains open.
模态对话框将是更简单的解决方案,因为您不需要在正在编辑的行上进行额外的验证-您一次只能编辑一行(而且我认为您无法在编辑时在主 View 中删除该行 window )。
如果希望在子窗口中完成的更改反射(reflect)在主网格中,则只需在主 View 中使用可观察的项目集合,并将该集合中的某些项目作为子窗口的DataContext传递即可。
关于wpf - 为了使用MVVM Light Tool Kit显示一些数据,在Modal Window和Dialog之间有什么好的选择?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12560361/