cfischer
cfischer

Reputation: 470

Navigate to another page at OnNavigatedTo?

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
}

Upvotes: 2

Views: 2304

Answers (1)

cfischer
cfischer

Reputation: 470

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

Upvotes: 7

Related Questions