使用带有框架控件的Prism NavigationService赢得通用应用程序 [英] Win universal app using Prism NavigationService with Frame control

查看:119
本文介绍了使用带有框架控件的Prism NavigationService赢得通用应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们如何将Prism NavigationService与Frame控件结合在一起? 我有一个包含框架的主页.首先,我必须导航到主页,之后要更改NavigationSerices,以便它使用框架而不是整个页面.

How to us the Prism NavigationService combined with the Frame control? I have a main page which includes a Frame. First, I have to navigate to the main page, after that I want to change the NavigationSerices so that it uses the Frame instead of the whole page.

因此,我需要Windows-Store-App-Prism框架中Prism 5.0中的区域.

So I need something like regions from Prism 5.0 in the Windows-Store-App-Prism framework.

一个类似的问题已经解决:

A similar problem was already solved: Register Navigation Service to Frame Element and NOT the page - WinRt Prism 2.0 but I don't like this solution.

推荐答案

解决方案:在继承自MvvmAppBase的App.xaml.cs中添加:

Solution: In the App.xaml.cs which inherits from MvvmAppBase add:

public static App Instance { get { return _instance; } }

private Type Resolve(string name)
{
    return Type.GetType(string.Format("{0}.Views.{1}Page", this.GetType().Namespace, name));
}

public void CreateNewNavigationFrame(Frame frame)
{
    this.NavigationService = new FrameNavigationService(new FrameFacadeAdapter(frame), Resolve, this.SessionStateService);
}

在主页(框架所在的页面)的构造函数中:

In the constructor of the main page (the page where the Frame is):

    public AppShellPage()
    {
        this.InitializeComponent();
        App.Instance.CreateNewNavigationFrame(this.frame);
    }

这篇关于使用带有框架控件的Prism NavigationService赢得通用应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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