Search code examples
c#c++-winrtwinui-3

Custom WinUI 3 C++/WinRT Control in C# WinUI project


I am trying to create WinUI C++/WinRT Component containing XAML control and iclude this custom control inside C# WinUI 3 project. Is this somehow possible? I had no luck yet. Could you please provide some examples if this is possible?

Reason:

Since WinUI 3 does not offer media player I want to make media player like this: https://github.com/asklar/WinAppSDK-MediaPlayer

EDIT:

So far I found WinRT APIs not supported in .NET 5 or later. I found there Windows.UI.Xaml (all classes in this namespace) which seems to be needed for creating custom c++/winrt control. After I read this I assume that it is not possible to consume custom C++/WinRT WinUI control in C# WinUI project.

enter image description here

Example:

Those are steps I created that projects.

  1. Create C# Library
  2. Create WinUI C++ Component
  3. Setup accordingly to MS Docs and Example
  4. Add WindowsSdk reference to library project
  5. Add custom control to C++ project

What I found possible is to consume custom C# WinUI contron inside WinUI C++/WinRT project, which seems to be way to go for me.


Solution

  • Issue should be fixed by updating Windows App SDK to 1.1.0-preview2. More information in this post.