Navigate to another page at OnNavigatedTo?

c++, c++-cx, events, microsoft-metro, winrt-xaml

Solution

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

Problem

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 } ```

Original source