Share via

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

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).