'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.
Example:
Those are steps I created that projects.
- Check this topic MS Docs
- Link to example
- Create C# Library
- Create WinUI C++ Component
- Setup accordingly to MS Docs and Example
- Add WindowsSdk reference to library project
- 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 1:[1]
Issue should be fixed by updating Windows App SDK to 1.1.0-preview2. More information in this post.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Michal Zhradnk Nono3551 |