同一区域内的棱镜视图切换
我有一个名为“ActiveModule”的区域,想要在不同的视图中重新使用它,例如,您按下搜索按钮,我会在其中显示搜索视图,等等。
我可以 ATM 做到这一点的唯一方法是停用该区域中的所有活动视图,然后激活我喜欢的视图,这有点脏,是否有“viewManager”或类似的东西我可以使用?
I have a region named "ActiveModule" and want to re-use it with different views, for example you press the search button and I show the search view in there, etc. etc.
The only way I can ATM do that is to deactivate all the active views in that region and then activate the view I like, this is a bit dirty, is there a "viewManager" or something similar I can use?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
如果您的区域是 ContentControl 或派生自 ContentControl,则一次只能有一个活动视图,并且您只需激活该区域上的搜索视图。
If your region is a ContentControl or derives from ContentControl, then there can only be one active view at a time, and you only need to activate the search view on the region.
您是否考虑过使用一种能够显示多个视图的 contentControl?
例如,您可以像这样使用 TabControl:
您现在可以向该区域添加多个视图。 使用 Prism 中的
INavigationAware
和IActiveAware
接口能够在视图上进行导航(激活它们、找到正确的视图等)。Did you consider to use a type of contentControl that is able to show multiple views?
For example you can use a TabControl like this:
You can now add more than one view to the region. Use
INavigationAware
andIActiveAware
interfaces from Prism to be able to do navigation on the views (activate them, find the correct view etc.).如果您使用的是
IRegionManager
,则可以删除您识别的所有类型的视图,然后添加您自己的视图。它绝不是理想的,但它确实有效。 :)
If you are using a
IRegionManager
, you can remove all of the views whose types you recognize and then add your own.Its by no means ideal, but it works. :)
据我所知,您正在做的事情是唯一的方法,理论上在 SCSF 中,最顶层的视图是由框架激活的。 您可以创建自己的 ViewManager 或等效的 ShowViewService 来完成此操作。 事实上,这就是我所做的!
To my knowledge what you are doing is the only way, theoretically in SCSF the top most view was activated by the framework. You could create ur own ViewManager or a ShowViewService equivalent to get this done. MAtter of fact, thats what i have done!
不确定您如何布局框架,但如果您使用与导航相关的框架,您只需调用
上面的行即可停用该区域中的其他视图。
否则,如果您确实进行视图发现或视图注入,则可以使用此处的方法
Not sure how you laid out your framework but if you are using navigation related framework you can simply call
the above line will take care of deactivating other views in the region.
Otherwise if you do view discovery or view injection you can use the approach here