应用程序的启动页面

应用程序的启动页面

本文介绍了如何更改 WP7 应用程序的启动页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 WP7 应用程序,我需要根据用户是否已经注册来更改启动页面.假设如果用户已注册,那么我需要将他重定向到欢迎页面,如果没有,则需要将其重定向到注册页面.

I am having an WP7 application in which I need to change the Startup page depending upon if the user is already registered or not. Suppose if user is registered then I need to redirect him to welcome page if not then to register page.

我尝试了以下几种方法是我的代码,但它给了我一个参数处理异常.

I have tried a couple of ways below is my code but it gives me an argument dispose exception.

为了实现上述功能,我在 MainPage.xaml 构造函数中编写了导航代码.检查用户注册信息是否不在独立存储中,然后将重定向到其他页面.

To achieve above feature I wrote Navigation code in my MainPage.xaml constructor. Checked if the User Registration info is not in isolated storage then will redirect to other page.

    private void IsAgreeed()
    {
        try
        {
            isoStorage = IsolatedStorageFile.GetUserStoreForApplication();
            if (!isoStorage.FileExists("DataBase/MyPhoneNumber.txt"))
            {
                this.NavigationService.Navigate(new Uri("/EULA.xaml", UriKind.Relative));
            }
            else
            {
                return;
            }
        }
        catch (Exception ex)
        {
            Debug.WriteLine(ex.ToString());

        }
    }

当我第一次使用上面的代码时它可以正常工作,但是如果我关闭应用程序并重新启动它,它会抛出异常参数处理异常.

Above code works properly when I use it first time but if I Close the Application and restart it again it throws exception argument dispose exception.

谢谢;无

推荐答案

Peter Torr 在这里很好地介绍了页面重定向.提供了两种方法,涵盖了相对优点.请注意,您可以重定向到登录页面,而不是使用弹出式建议进行登录处理.

Peter Torr covers page redirections quite well here. Two methods are offered with relative merits covered. Note you can redirect to a login page, rather then employing the popup suggestion for login handling.

重定向初始导航 - Peter Torr 的博客

我还建议您熟悉他随附的有关地点的帖子.

I'd also recommend familiarising with his accompanying post on places here.

介绍场所"的概念 - Peter Torr 的博客

此地址返回堆栈处理(认证考虑)并解决登录页面等场景.

This address back stack handling (certification consideration) and addresses scenarios such as login pages.

这篇关于如何更改 WP7 应用程序的启动页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 00:10