CppWinRT.Builders
0.0.14
dotnet add package CppWinRT.Builders --version 0.0.14
NuGet\Install-Package CppWinRT.Builders -Version 0.0.14
<PackageReference Include="CppWinRT.Builders" Version="0.0.14" />
paket add CppWinRT.Builders --version 0.0.14
#r "nuget: CppWinRT.Builders, 0.0.14"
// Install CppWinRT.Builders as a Cake Addin #addin nuget:?package=CppWinRT.Builders&version=0.0.14 // Install CppWinRT.Builders as a Cake Tool #tool nuget:?package=CppWinRT.Builders&version=0.0.14
CppWinRT.Builders
Add-on NuGet package to generate C++ builder-style helpers for WinRT objects.
Motivation
In C++/WinRT, setters are implemented as method calls that return void
.
This means that creating a button from code looks like:
auto button = Controls::Button();
button.Height(40);
button.Width(200);
button.Content(winrt::box_value(L"Hello"));
This can get repetitive, and some developers prefer a more fluent style. CppWinRT.Builders enables you to write this instead:
#include <winrt/builders/Windows.UI.Xaml.Controls.Button.h>
auto button = Controls::builders::Button()
.Height(40)
.Width(200)
.Content(winrt::box_value(L"Hello"));
Collections (such as types that derive from IVector<T>
and IMap<T>
) can also be initialized via C++ initializer lists:
auto sp = Controls::builders::StackPanel{}
.Children({
Controls::builders::Button{}
.Height(40)
.Width(200)
.Content(winrt::box_value(L"Hello")),
Controls::builders::Button{}
.Height(40)
.Width(200)
.Content(winrt::box_value(L"world")),
})
.Resources({
{ winrt::box_value(L"SomeKey"), winrt::box_value(42) }
})
.Background(Media::SolidColorBrush{ Windows::UI::Colors::AliceBlue() })
.Padding(ThicknessHelper::FromUniformLength(8))
.Orientation(Controls::Orientation::Horizontal);
Formatters
The tool in this package also generates string formatters for enums. To use:
#include <winrt/formatters/Windows.UI.Xaml.Visibility.h>
// ...
auto visibility = Visibility::Collapsed;
std::wcout << visibility << std::endl; // prints "Collapsed"
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
native | native is compatible. |
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.