Revvz
Revvz

Reputation: 525

Compile-Time Error When Navigating Between Pages C++/WinRT Windows App SDK

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:

Upvotes: 1

Views: 377

Answers (1)

paybos
paybos

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

Related Questions