Windows Phone的装载后立即页面导航 [英] windows phone navigation immediately after loading page

查看:188
本文介绍了Windows Phone的装载后立即页面导航的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2页。(MainPage.xaml中,second.xaml)
MainPage.xaml中的登录页面。在这个页面我发送登录名和密码,并接受结果。我保存(结果)在隔离储存,并导航到second.xaml页面;
当我开始在接下来的时间这个应用程序,我提取分离存储的数据,我想immidiately导航second.xaml,但我不知道如何



我试着写

 公开的MainPage()
{
的InitializeComponent();

//一种孤立存储
InitializeSet​​tings功能();
NavigationService.Navigate(新的URI(/ Conversation.xaml,UriKind.Relative));
}



但它不工作)
我知道,我可以不要同时使用的MainPage()构造函数相关的导航代码。当然,我可能会做简单的按钮,但我希​​望快速导航



我认为可能是它的App.xaml方法连接

 私人无效Application_Launching(对象发件人,LaunchingEventArgs E)

例如,写我的方法

 一种孤立存储
InitializeSet​​tings //函数();



导航呢?(导航本例中没有工作)

 私人无效Application_Launching(对象发件人,LaunchingEventArgs E)
{
InitializeSet​​tings();
NavigationService.Navigate(新的URI(/ Conversation.xaml,UriKind.Relative));
}



我在哪里可以使用导航,所以直奔second.xaml页面,


解决方案

您可以做林蛙Tallal说。

或者你也可以在代码中写:

 公开的MainPage()
{
的InitializeComponent();

加载+ =(S,E)=>
{
InitializeSet​​tings();

//一些登录密码检查条件
如果(_login&安培;&安培; _password)
NavigationService.Navigate(新的URI(/ Conversation.xaml,
UriKind.Relative));
}
}


I have 2 pages.(MainPage.xaml,second.xaml) MainPage.xaml is the Login page. In this page I send login and password, and receive result. I save them(result) in Isolate Storage and navigate to the second.xaml page; When i start this application in the next time, i extract data from Isolate Storage and I want to navigate the second.xaml immidiately, but i don't know how

I try write

public MainPage()
    {
        InitializeComponent();

       //function for Isolate storage
        InitializeSettings();
        NavigationService.Navigate(new Uri("/Conversation.xaml", UriKind.Relative));
    }

But it isn't work) I understood that I could not use the navigation code associated with the MainPage() constructor. Of course, i may will do simple button, but i wish fast navigation

I think may be it connected with App.xaml method

private void Application_Launching(object sender, LaunchingEventArgs e)

for example, write my method

        //function for Isolate storage
        InitializeSettings();

with navigation there?(navigation not work in this example)

private void Application_Launching(object sender, LaunchingEventArgs e)
{
InitializeSettings();
 NavigationService.Navigate(new Uri("/Conversation.xaml", UriKind.Relative));
}

Where I can use navigation, so go straight to the second.xaml page, without fully loading the MainPage.xaml(may be without MainPage.xaml)

解决方案

You can do as Rana Tallal said.

Or you can write it in code:

public MainPage()
{
    InitializeComponent();

    Loaded += (s, e) =>
    {
        InitializeSettings();

        // Some login-password check condition
        if (_login && _password)
            NavigationService.Navigate(new Uri("/Conversation.xaml",
                                               UriKind.Relative));
    }
}

这篇关于Windows Phone的装载后立即页面导航的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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