How to set up an C# Markup project for Toolkit

In this tutorial, you'll learn how to set up an Uno Platform project to use C# Markup.

  1. Make sure your environment is set up properly by using uno check.

  2. You can create a Uno App by either using the Uno Platform Visual Studio extension or via the command line interface.

    Using Visual Studio 2022 Uno Platform Extension

    • Open the Visual Studio and select Extensions => Manage Extensions and Search (Ctrl + E) for unoplatform.

    • Make sure you have the latest version of Uno Extension (v5.0 or higher) installed.

      Screenshot displaying how to check the version of the Uno Extension wizard version in Visual Studio extension manager

    • Press Ctrl+Shift+N to create a new project and select "Uno Platform App".

    • Give your project an appropriate name (MySampleToolkitProject in this page).

    • When prompted Select Blank and click Customize

      Screenshot displaying the intro screen of the Uno Extension wizard in Visual Studio

    • In the Markup tab (4rd one), select C# Markup.

      Screenshot displaying how to pre-install C# Markup in the generated project

    • In the Features tab (7rd one), select Toolkit.

      Screenshot displaying how to pre-install Toolkit in the generated project

    • Click Create on the bottom right corner.

Toolkit References

Looking in detail at the projects with the addition of the Toolkit, we can see the addition of some additional references. This allows an easy inclusion of the Toolkit in existing projects.

  1. Add the references to the Directory.Packages.props file (with the updated version).

    <PackageVersion Include="Uno.Toolkit.WinUI" Version="0.0.0" />
    <PackageVersion Include="Uno.Toolkit.WinUI.Markup" Version="0.0.0" />
    
  2. Add the package to the following projects:

    • PROJECT_NAME.Wasm.csproj
    • PROJECT_NAME.Mobile.csproj (or PROJECT_NAME.iOS.csproj, PROJECT_NAME.Droid.csproj, PROJECT_NAME.macOS.csproj if you have an existing project)
    • PROJECT_NAME.Skia.Gtk.csproj
    • PROJECT_NAME.Windows.csproj (or PROJECT_NAME.UWP.csproj for existing projects)
    <PackageReference Include="Uno.Toolkit.WinUI.Markup" />
    

Choose either:

  • The Uno.Toolkit.UI package when targeting Xamarin/UWP
  • The Uno.Toolkit.WinUI package when targeting net6.0+/WinUI