我无法从其他页面(而不是MainPage.xaml)动态地启动Windows Phone应用程序。这是代码:
public MainPage()
{
InitializeComponent();
if (appSettings["Parse.CurrentUser"] != null)
{
MessageBoxResult result = MessageBox.Show("Welcome Back","Welcome",MessageBoxButton.OK);
this.NavigationService.Navigate(new Uri("/email.xaml", UriKind.RelativeOrAbsolute));
//Above step causes error as a Null Exception. :(
}
else
{
// show the signup or login screen
}
}
因此,如果用户已经被盗了,我不想显示MainPage,而是想显示email.xaml页面。请帮忙NullException
。
NavigationService
在页面构造函数中尚不可用。尝试将代码从页面的构造函数移动到页面的OnNavigatedTo()
事件:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
if (appSettings["Parse.CurrentUser"] != null)
{
MessageBoxResult result = MessageBox.Show("Welcome Back","Welcome",MessageBoxButton.OK);
this.NavigationService.Navigate(new Uri("/email.xaml", UriKind.RelativeOrAbsolute));
}
else
{
// show the signup or login screen
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句