1

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
Revvz
  • 455
  • 1
  • 6
  • 14
  • The `System.` namespace is used by the .NET projections exclusively. Does your project somehow reference .NET? – IInspectable May 08 '22 at 15:22
  • It references `Microsoft.Windows.System` and others, but those are all "Unresolved References". See [this image](https://i.imgur.com/u7D8usL.png). – Revvz May 08 '22 at 15:33
  • There is no `Xaml` namespace under `Microsoft.Windows.System`. This is a different `System.` namespace. We can safely preclude the SDK, C++/WinRT, and WIL from the problem space. Now, both the Windows App SDK and the Visual Studio teams have support channels. Have you asked them for feedback, provided that you have a [mcve] to demonstrate the issue? – IInspectable May 08 '22 at 15:44
  • I have not asked them yet. Would you mind pointing me to their respective support channels? I'll work on a minimal reproducible example in the mean time. Thank you very much for your help. – Revvz May 08 '22 at 16:20
  • Actually, I think the issue is with creating new pages. If I add a [new item] `Blank Page (C++/WinRT)` it has the error I'm getting. I didn't edit anything in the new page. – Revvz May 08 '22 at 16:32
  • 1
    Github channel for Winui3 and windows app sdk: https://github.com/microsoft/microsoft-ui-xaml – Ax1le May 09 '22 at 03:21

1 Answers1

1

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

paybos
  • 11
  • 1