在一个区域的Prism中的视图之间切换. [英] Switching between the views in Prism on a region.

查看:164
本文介绍了在一个区域的Prism中的视图之间切换.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我的要求是要有一个区域,并且要根据按钮的点击在视图之间进行切换.
我有一个绑定到两个按钮的NavigateCommand,该命令的执行功能类似于以下代码片段.
      

Hi, 
My requirement is I have a region and I wll be switching between the views based on button click. 
I have a NavigateCommand which is binded to two buttons and my execute function of the command looks like the below snippet.
      

 void Navigate(object result)
    {
        if (result != null)
        {
            if (result.ToString() == "UserControlA")
            {
                _regionManager.RequestNavigate("myregion", new Uri("UserControlA", UriKind.Relative));
            }
            else
            {
                _regionManager.RequestNavigate("myregion", new Uri("UserControlB", UriKind.Relative) });

            }
        }
    }



在开始学习有关按需加载模块的知识之前,我很高兴在一个区域的视图之间切换.
我浏览了链接"https://www.codeproject.com/Articles/41931/Composite-WPF-Display-on-Demand". 在此链接中,使用Activate和DeActivate方法向/从该区域添加视图/从中删除视图,如



I was happily switching between the views on a region until I started learning about Loading modules on Demand. 
I went through a link "https://www.codeproject.com/Articles/41931/Composite-WPF-Display-on-Demand". 
In this link the Activate and DeActivate methods were used to add/remove views to/from hte region, like . 

// Activate Module A view
var moduleAView = mainRegion.GetView("ModuleA.ModuleAView");
mainRegion.Activate(moduleAView);
// Remove existing views
foreach (var oldViewName in region.Views)
{
    var oldView = region.GetView(oldViewName);
    region.Deactivate(oldView);
}



这种技术与我上面提到的技术有什么区别?请解释.

谢谢,
Sanjay.



what is the difference between this technique and the one that I mentioned above or am I mission something here. kindly explain. 

Thanks, 
Sanjay.

推荐答案

>>>此技术与我上面提到的技术或我在这里执行的任务之间有什么区别?

第二种技术称为视图注入.它允许视图以编程方式显示在特定区域中.这是显式的程序化导航的一种形式.

The second technique is called view injection. It allows views to be programmatically displayed in a specific region. This is a form of an explicit, programmatic navigation.

Prism 4中引入了区域管理器的RequestNavigate方法,以基于URI支持更通用的导航概念.

The RequestNavigate method of the region manager was introduced in Prism 4 to support a more general notion of navigation, based on URIs.

您可以选择在整个应用程序中使用它们中的任何一个或将它们组合在一起.请参考以下链接,了解有关在Prism中导航的更多信息: https://msdn.microsoft.com/zh-CN/library/gg430861%28v=pandp.40%29.aspx

You could choose to use either of them or combine them both throughout your application. Please refer to the following link for more information about navigation in Prism: https://msdn.microsoft.com/en-us/library/gg430861%28v=pandp.40%29.aspx


希望有帮助.


Hope that helps.

请记住,通过将有用的帖子标记为答案来关闭话题,然后在遇到新问题时开始新话题.请不要在同一线程中问几个问题.

Please remember to close your threads by marking helpful posts as answer and then start a new thread if you have a new question. Please don't ask several questions in the same thread.


这篇关于在一个区域的Prism中的视图之间切换.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆