Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/EmptyTag/149.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在模块中使用prism导航多个视图_C#_Wpf_Navigation_Prism - Fatal编程技术网

C# 如何在模块中使用prism导航多个视图

C# 如何在模块中使用prism导航多个视图,c#,wpf,navigation,prism,C#,Wpf,Navigation,Prism,我是Prism的新手,所以需要一些视图导航方面的帮助 在我的项目中,我只有4个视图,所以我在一个模块中创建了所有视图。我已经创建了shell和引导程序。我需要做的是,我需要将一些数据从一个视图传递到另一个视图(例如,第一个视图有员工列表,我选择一个员工,我将单击按钮以获取该员工的详细信息)。目前我使用的是ViewModel优先方法` _container.RegisterType<DashboardView>(); _container.RegisterType<Prepare

我是Prism的新手,所以需要一些视图导航方面的帮助 在我的项目中,我只有4个视图,所以我在一个模块中创建了所有视图。我已经创建了shell和引导程序。我需要做的是,我需要将一些数据从一个视图传递到另一个视图(例如,第一个视图有员工列表,我选择一个员工,我将单击按钮以获取该员工的详细信息)。目前我使用的是ViewModel优先方法`

_container.RegisterType<DashboardView>();
_container.RegisterType<PrepareRunView>();

_container.RegisterType<IDashboardViewViewModel, DashboardViewViewModel>();
_container.RegisterType<IPrepareRunViewViewModel, PrepareRunViewViewModel>();
_regionManager.RegisterViewWithRegion(RegionNames.MainRegion, typeof(DashboardView));
_regionManager.RegisterViewWithRegion(RegionNames.MainRegion, typeof(PrepareRunView));
\u container.RegisterType();
_container.RegisterType();
_container.RegisterType();
_container.RegisterType();
_regionManager.RegisterViewWithRegion(RegionNames.MainRegion,typeof(DashboardView));
_regionManager.RegisterViewWithRegion(RegionNames.MainRegion,typeof(PrepareRunView));
  • 在这种情况下,如何在视图和传递数据之间进行导航
  • 我需要在模块类初始化函数中指定什么
  • 此外,在模块类中,当我注册同一区域的两个视图时,我能够看到这两个视图,所以我还需要激活和停用我的视图


    提前感谢

    您可以使用事件聚合器进行通信


    第一个视图(选择员工的视图)的视图模型需要引用Prism的IRegionManager对象。导航到第二个视图并按如下方式向其传递一些数据,非常类似于URL中的查询字符串值:-

    var uriQuery = new UriQuery();
    uriQuery.Add("empid", "123");
    // Add more name/value pairs if you wish!
    
    var viewName = "your_view_name" + uriQuery;
    
    _regionManager.RequestNavigate("your region name", viewName);
    
    如您所见,您可以通过指定视图名称导航到视图。为了实现这一点,您需要在IoC容器的名称下注册视图(如何注册取决于您使用的容器)

    在要导航到的视图的视图模型中,实现INavigationAware界面:-

        public bool IsNavigationTarget(NavigationContext navigationContext)
        {
            return true;
        }
    
        public void OnNavigatedFrom(NavigationContext navigationContext)
        {
        }
    
        public void OnNavigatedTo(NavigationContext navigationContext)
        {
            // This will be called whenever the view is navigated to.
            // Extract the querystring value(s).
            var employeeId = navigationContext.Parameters["empid"];
            .. etc..
        }
    

    如何在模块中激活和停用视图?谢谢,您如何在模块文件中激活和停用视图?这就像当我导航到不同的屏幕时,我需要激活新的屏幕。