导航到OnNavigatedTo的另一个页面?

时间:2012-11-14 09:29:39

标签: c++ events microsoft-metro winrt-xaml c++-cx

为什么在此页面的Navigate事件中调用时方法OnNavigatedTo不起作用?

这种行为是否适合您?

任何想法如何避免这个问题?

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 个答案:

答案 0 :(得分:7)

为了获得正确的行为,我现在正在使用调度程序:

    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));
    }));