问题
Why does the method Navigate not work when called in the OnNavigatedTo event of this page?
Is this behavior reproducible for you?
Any ideas how to avoid this problem?
void LockScreenPage::OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e)
{
//if user has no PIN protection
this->Frame->Navigate(Windows::UI::Xaml::Interop::TypeName(AnotherPage::typeid));
//else verify PIN
}
回答1:
To get the right behavior I am now using the dispatcher:
this->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal, ref new Windows::UI::Core::DispatchedHandler([this] () {
this->Frame->Navigate(Windows::UI::Xaml::Interop::TypeName(AnotherPage::typeid));
}));
来源:https://stackoverflow.com/questions/13376122/navigate-to-another-page-at-onnavigatedto