WinUI: How to set the NavigationTransitionInfo in Frame.Navigate Method

youki 996 Reputation points
2022-06-23T19:03:46.39+00:00

Hello,
How to set it as parameter in c++ ??? (I don't get it)

ContentFrame().Navigate(winrt::xaml_typename<winrt::App1::Page1>(), NULL, ???);  

Regards

Edited:

Ok,
I have an other issue.

I've got 2 pages which i load into the frame within the MainWindow.xaml.

I've created a static variable to have access to the frame:

winrt::App1::implementation::MainWindow *MainWindow::s_mainWindow;  

If i call a page with 1 parameter, it works.

MainWindow::s_mainWindow->ContentFrame().Navigate(winrt::xaml_typename<winrt::App1::EditProcess>());  

If i call it with 3 parameters, i have an unresolved external symbol...

#include "pch.h"  
#include "MainPage.xaml.h"  
#if __has_include("MainPage.g.cpp")  
#include "MainPage.g.cpp"  
#endif  
  
#include "winrt/Windows.UI.Xaml.Interop.h"  
#include "EditProcess.xaml.h"  
#include "MainWindow.xaml.h"  
  
  
using namespace winrt;  
using namespace Microsoft::UI::Xaml;  
  
// To learn more about WinUI, the WinUI project structure,  
// and more about our project templates, see: http://aka.ms/winui-project-info.  
  
namespace winrt::App1::implementation  
{  
    MainPage::MainPage()  
    {  
        InitializeComponent();  
    }  
  
    int32_t MainPage::MyProperty()  
    {  
        throw hresult_not_implemented();  
    }  
  
    void MainPage::MyProperty(int32_t /* value */)  
    {  
        throw hresult_not_implemented();  
    }  
}  
  
  
void winrt::App1::implementation::MainPage::MenuFlyoutItem_New_Click(winrt::Windows::Foundation::IInspectable const& sender, winrt::Microsoft::UI::Xaml::RoutedEventArgs const& e)  
{  
        MainWindow::s_mainWindow->ContentFrame().Navigate(winrt::xaml_typename<winrt::App1::EditProcess>(), nullptr,  
        Microsoft::UI::Xaml::Media::Animation::EntranceNavigationTransitionInfo());  
}  

214506-image.png

Is it because of the way accessing the frame?

Windows App SDK
Windows App SDK
A set of Microsoft open-source libraries, frameworks, components, and tools to be used in apps to access Windows platform functionality on many versions of Windows. Previously known as Project Reunion.
727 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,544 questions
0 comments No comments
{count} votes

Accepted answer
  1. Castorix31 81,831 Reputation points
    2022-06-23T19:39:45.417+00:00

    You can see the MS samples in C# and C++ at NavigationView

    with the function

    void MainPage::NavView_Navigate(  
            std::wstring navItemTag,  
            Windows::UI::Xaml::Media::Animation::NavigationTransitionInfo const& transitionInfo)  
    

    which calls

     ContentFrame().Navigate(pageTypeName, nullptr, transitionInfo);  
    

    with parameters :

      NavView_Navigate(L"home", Windows::UI::Xaml::Media::Animation::EntranceNavigationTransitionInfo());   
    

    (replace Windows::UI::Xaml::Media::Animation::EntranceNavigationTransitionInfo() by

    Microsoft::UI::Xaml::Media::Animation::EntranceNavigationTransitionInfo())


0 additional answers

Sort by: Most helpful