WPF Prism Master 详细信息表单
我正在使用 WPF 创建一个应用程序,该应用程序使用 Prism 框架。 我已经创建了 Shell 表单,并在其中为工具栏、菜单栏和工作区定义了区域。 在工作区中,我能够加载模块,但我有一个要求,即我必须加载“员工主表”表单,以在网格中显示所有员工列表。双击网格中的该员工行,它应该导航到“员工详细信息”表单。在这里我不应该使用 Tab 控件。双击员工网格时,员工主表单应关闭或卸载,员工详细信息屏幕应加载。
Prism 专家对此有何建议。
谢谢和问候, 哈利
I am creating an application using WPF which is using Prism framework.
I have created Shell form and defined regions in that for Toolbar, Menubar and Workspace.
In the workspace area, i am able to load the modules, but I got one requirement where I have to load Employee Master form showing all the employee list in grid. On double click of that employee row in grid it should navigate to the Employee details form. Here I am not supposed to use the Tab control. On double click of the employee grid the Employee Master form should get closed or unloaded and Employee details screen should get loaded.
Any suggestions from Prism Experts on this.
Thanks and Regards,
Harry
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我发现在这些场景中,人们正在寻找“棱镜化”他们的解决方案的地方。 我关于何时在 Prism 中使用 EventAggregator 的经验法则:
以下是 我唯一一次使用 EventAggregator 来解决问题。否则,我只使用 WPF 中内置的机制。特别是在主/从场景中,这两个视图可能只有在一起才有用,使它们在逻辑上是相同的视图,而不是单独的视图。
在这种情况下,我通常会这样做(我在这种情况下省略了适当的 DataTemplates,但希望这足以说明您不需要任何花哨的东西来解决这个问题)。
这使用了一个简单的 WPF 机制,该机制显示集合中的项目列表,当用户选择一个项目时,“Turtles/”的值将更改为所选项目。简单的。没必要把事情搞得太复杂。
如果您确实觉得您的场景需要 EventAggregator(符合上面的规则 #1 和 #2),那么请尽可能简单地执行...侦听由视图模型引发的事件并从视图模型中使用它(你正在使用 MVVM,对吧?)。再多一点就头疼了。
I find that in these scenarios, people are looking for places to "Prism-ify" their solution. Here's my rule-of-thumb for when to use EventAggregator in Prism:
Those are the only times I would use EventAggregator to solve a problem. Otherwise, I just use the mechanisms built into WPF. Specifically in a master/detail scenario, the two views are likely useful only together, making them logically the same view, rather than seperate views.
This being the case, I typically do something like this (I've omitted the appopritate DataTemplates in this scenario, but hopefully this is enough to illustrate you don't need anything fancy to solve this problem).
This uses a simple WPF mechanism that displays a list of items in a collection and when the user selects an item, the value of "Turtles/" is changed to the item selected. Simple. No need to over-complicate things.
If you really feel like your scenario warrants an EventAggregator (fits with rules #1 and #2 above), then do so as simply as possible... listen to an event both raised by a view model and consume it from a view model (you are using MVVM, right?). Anything more is a headache.
我会为此使用事件聚合器或可能使用新的 VisualStateManager。
我在 PRISM 中陷入的陷阱之一是对设计的过度思考。我最终停止使用它并将其从我的项目中删除,事情变得好多了。虽然我仍然使用并喜欢事件聚合器...但是整个区域和视图状态的事情有一个很大的学习曲线...
I would use an eventaggregator for this or possibly the new VisualStateManager.
One of the traps I fell into with PRISM is overthinking the designs. I eventually stopped using it and ripped it out of my project and things have been going much nicer. Though I still use and love eventaggregator...but theres a big learning curve on the whole regions and viewstate thing...