当应用程序在Windows Phone 8中启动时,如何显示不同的页面

时间:2013-10-10 00:57:38

标签: windows-phone-8

当app启动时需要显示注册page.once用户注册它不应该去注册页面需要登录页面。怎么做到这一点?

1 个答案:

答案 0 :(得分:0)

由于您使用Isolated Storage存储密码,因此您只需使用此密码即可。

public MainPage()
{
    InitializeComponent();
    Loaded += MainPage_Loaded; 
}

void MainPage_Loaded(object sender, RoutedEventArgs e)
{
    if (IsolatedStorageSettings.ApplicationSettings.Contains("LoginPassword"))
    {
        // so, if login password has already registered, it will redirect to LoginPage
        NavigationService.Navigate(new Uri("/LoginPage.xaml", UriKind.Relative));
        //else it will be in MainPage where user can enter their password
    }
}

不要忘记在“登录页面”中添加此代码,这将限制用户不再返回“MainPage”;

protected override void OnNavigatedTo(NavigationEventArgs e)
{
    while (NavigationService.CanGoBack)
    {
        NavigationService.RemoveBackEntry();
    }
}