When my UserLogin
页面加载时,我想检查用户数据库,如果它不存在或无法读取,我想将其定向到NewUser
page.
protected override void OnNavigatedTo(NavigationEventArgs e)
{
CheckForUser();
if (UserExists == false)
this.Frame.Navigate(typeof(NewUser));
}
问题是它永远不会导航到NewUser
,即使我注释掉if
健康)状况。
Navigate
不能直接调用表单OnNavigatedTo
方法。您应该通过调用您的代码Dispatcher
它会起作用:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
CheckForUser();
if (UserExists == false)
Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
() => this.Frame.Navigate(typeof(NewUser)));
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)