Shell 布局和切换视图的最佳实践 - Prism、SL4、按需加载模块
我正在学习 Prism,我有一个关于主 Shell 的最佳方法的问题。
假设 Shell 有 2 个区域:工具栏、主区域。 工具栏有 3 个主要按钮,每个按钮代表不同的按需加载模块。 这些模块中的每一个目前都将自己注册为适合主区域。
当我单击其中一个按钮时,我想要执行以下操作:
通知任何活动视图其正在切换,如果仍需要挂起的操作,则可以选择取消。 这可能会级联到子视图。
如果操作未取消,则加载按需模块(如果尚未加载),否则在区域内激活它。
这三个模块是否应该全部适合同一区域,或者我的 shell 是否应该在内容演示器中定义 3 个区域?
我遇到的问题之一是,当您从模块初始化注册视图时,它不会添加强类型名称,因此当我尝试确定我的视图是否已使用 GetView( viewname) 它总是返回 null,所以我最终向该区域添加了另一个视图。
I am learning Prism, and I have a question on the best approach for the main Shell.
Assuming the Shell has 2 regions: Toolbar, Main.
The toolbar has 3 main buttons that each represent a different On Demand Load Module.
Each of these modules currently register themselves as fitting in the Main Region.
When I click one of the buttons I want to do the following:
Notify any active view that its switching, with an option to cancel if there is a pending action still required.
This might cascade to child views.
If the action isn't cancelled then load the on demand module if it has not yet been loaded, else activate it within the region.
Should these three modules all fit in the same Region or should my shell have 3 regions defined within content presenters?
One of the areas I got stuck on was that when you register a view from the Module Initialize, it doesn't get added with a strongly typed name, so when I tried to determine if my view was already added to the region with GetView(viewname) it always returns null, so I end up adding another view to the region.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将所有视图注册在同一区域(例如“MenuRegion”)是一个好方法。至于检查脏视图,您可能会发现 Brian Noyes 的这篇博客文章很有用:
从 WPF Prism 应用程序关闭时保存
我希望这会有所帮助。
谢谢,
达米安
Having all views register in the same region (say "MenuRegion") is a good approach. As for checking for dirty views you might find this blog post from Brian Noyes useful:
Saving on Close From a WPF Prism App
I hope this helps.
Thanks,
Damian