Skip to content

C++/WinRT: Labs 0.8.0-alpha requires manual XamlToolkit.Labs.WinUI.h include in consumer project #24

Open

Description

@tpoint75

Description

After upgrading XamlToolkit.Labs.WinUI.Native from 0.7.0-alpha to 0.8.0-alpha, my C++/WinRT WinUI 3 application no longer builds.

The XAML-generated metadata code references the Labs metadata provider:

_otherProviders.push_back(
    ::winrt::XamlToolkit::Labs::WinUI::XamlMetaDataProvider());

but the corresponding C++/WinRT projection is not visible to the generated code:

#include <winrt/XamlToolkit.Labs.WinUI.h>

The compiler reports:

'Labs': the symbol to the left of '::' must be a type

The same application builds with 0.7.0-alpha.

Generated code

XamlTypeInfo.g.cpp automatically includes projections for other toolkit namespaces, for example:

#if __has_include(<winrt/XamlToolkit.WinUI.Controls.h>)
#include <winrt/XamlToolkit.WinUI.Controls.h>
#endif

However, no equivalent include is generated for:

#include <winrt/XamlToolkit.Labs.WinUI.h>

At the same time, the generated XAML metadata code references:

::winrt::XamlToolkit::Labs::WinUI::XamlMetaDataProvider()

Workaround

Adding the Labs projection manually to the consumer application's pch.h fixes the build and the application runs correctly:

#include <Windows.h>

// Prevent conflict with Storyboard::GetCurrentTime
#undef GetCurrentTime

#include <winrt/XamlToolkit.Labs.WinUI.h>

The include has to be placed after #undef GetCurrentTime; otherwise the Windows GetCurrentTime macro causes additional compilation problems.

Project configuration

  • WinUI 3
  • C++/WinRT
  • C++20 C++/WinRT modules enabled
  • Native XamlToolkit NuGet packages

The application uses these XAML namespaces:

xmlns:ui="using:XamlToolkit.WinUI"
xmlns:controls="using:XamlToolkit.WinUI.Controls"
xmlns:convertors="using:XamlToolkit.WinUI.Converters"
xmlns:labs="using:XamlToolkit.Labs.WinUI"
xmlns:media="using:XamlToolkit.WinUI.Media"

Versions

Works:

XamlToolkit.Labs.WinUI.Native 0.7.0-alpha

Fails unless the Labs projection is manually included:

XamlToolkit.Labs.WinUI.Native 0.8.0-alpha

Expected behavior

Updating from 0.7.0-alpha to 0.8.0-alpha should not require the consumer project to manually add:

#include <winrt/XamlToolkit.Labs.WinUI.h>

just to compile the generated XamlMetaDataProvider code.

It would be useful to know whether this is a packaging/regression issue in 0.8.0-alpha or whether an additional consumer-side configuration is now required.

Activity

  1. changed the title [-][C++/WinRT] Labs 0.8.0-alpha requires manual XamlToolkit.Labs.WinUI projection include in consumer project[/-] [+]C++/WinRT: Labs 0.8.0-alpha requires manual XamlToolkit.Labs.WinUI.h include in consumer project[/+] on Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions