Reputation: 525
I have been trying for a long time to get page navigation to work in a Windows App SDK C++/WinRT-based app, to no avail. I have two pages and I'm trying to navigate from Page 1 to Page 2 via code-behind in an event handler. I have tried embedding a Frame
within Page 1's Window
and then using that to call something like myFrame.Navigate(xaml_typename<...>());
and I have tried using the following code:
Frame rootFrame{ nullptr };
auto content = Window::Current().Content();
if (content) rootFrame = content.try_as<Frame>();
rootFrame.Navigate(xaml_typename<...>());
Which can be found here.
They all produce the same error:
WMC9999 Unable to cast object of type 'System.Xaml.XamlType' to type 'Microsoft.UI.Xaml.Markup.Compiler.DirectUI.DirectUIXamlType'
Software Versions:
Windows App SDK 1.1.0-preview3
Windows SDK Build Tools 10.0.22000.194
CppWinRT 2.0.210806.1
Windows ImplementationLibrary 1.0.211019.2
Visual Studio 2022
Upvotes: 1
Views: 377
Reputation: 11
In the idl file you need to change Windows.UI.Xaml.Controls.Page to Microsoft.UI.Xaml.Controls.Page.
The tooling is a little under cooked. enter image description here
Upvotes: 1