C# Windows Runtime Component WinUI Controls Sample
This sample demonstrates how to author C# components with WinUI controls (User Control and Custom Control) using C#/WinRT, and how to consume these components from C++ and C# apps.
The sample solution includes the following application projects:
- CppApp (packaged C++ WinUI app)
- CppAppUnpackaged (unpackaged C++ WinUI app)
- CsApp (packaged C# WinUI app)
All the application projects have a project reference to the C# Windows Runtime component library project, WinUICsComponent. The C# component uses the Microsoft.Windows.CsWinRT NuGet package to generate a Windows Runtime Component with custom WinUI controls.
Prerequisites
- See System requirements for Windows app development.
- Make sure that your development environment is set up correctly—see Install tools for developing apps for Windows 10 and Windows 11.
Building and running the sample
- Open the solution file (
.sln) in Visual Studio. - Set one of the application projects as the startup project.
- From Visual Studio, either Start Without Debugging (Ctrl+F5) or Start Debugging (F5).