【问题标题】:Navigate to another page at OnNavigatedTo?导航到 OnNavigatedTo 的另一个页面?
【发布时间】:2012-11-02 18:57:10
【问题描述】:

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

这种行为可以重现吗?

有什么办法可以避免这个问题吗?

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
}

【问题讨论】:

  • 恐怕我没有答案,但是您为什么要这样做而不是导航到您想要的页面?
  • 我正在开发的应用程序有一个锁定屏幕,在启动应用程序时会打开。如果用户没有启用 PIN 保护,我将导航到另一个页面。

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


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-08-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-16
    • 2012-09-18
    • 2021-09-20
    • 2020-07-27
    相关资源
    最近更新 更多