Navigate to another page at OnNavigatedTo?

走远了吗. 提交于 2019-12-02 05:27:54

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!