Thank you for your interest in contributing to DevWinUI! 🎉
This guide will help you get started with setting up your development environment, following project conventions, and contributing code or samples effectively.
To get started quickly, watch these YouTube video tutorials:
Tip
Please confirm that your development environment meets the requirements before compiling.
Ensure that your installation includes the appropriate workloads:
- On the Workloads tab of the Visual Studio installer, check:
- .NET Desktop Development
- WinUI Application Development
You can also import the configuration file (.vsconfig file) into a new or existing Visual Studio installation.
Open the Visual Studio Installer and close Visual Studio. Most Installer operations require that the Visual Studio product itself is closed.
On either the Installed tab or the Available tab, select More > Import configuration on the Visual Studio product card.
Locate the .vsconfig file that you want to import, and then choose Review details.
Verify that your selections are accurate, and then choose Modify.
Ensure that you have following installed:
- .NET 8.x
- .NET 9.x
- .Net 10.x
- Windows 10 SDK (10.0.19041)
Windows 10 SDK 10.0.19041 does not exist in Visual Studio Installer, you need to download and install it manually from here
https://learn.microsoft.com/en-us/windows/apps/windows-sdk/downloads
Make sure your environment matches these requirements to avoid issues during compilation.
DevWinUI/
dev/
DevWinUI/ # Full Library (Custom controls and Styles and Base Library)
Themes/ # Styles, templates, and resources
DevWinUI.Base/ # Core Library
DevWinUI.ContextMenu/ # Cross-platform context menu logic
DevWinUI.SourceGenerator/ # Source Generators
DevWinUI.Gallery/ # Demo app for controls
VSIX/ # Source code for Visual Studio item templates
Output/ # Generated NuGet packages
Clean-obj-bin.bat # Helper script to clear build artifacts
Directory.Build.props # Central project configuration- All XAML files must be formatted using XAML Styler
- The settings are defined in
settings.xamlstylerlocated in the root directory. - Run XAML Styler on any new or updated XAML files before committing.
To fix certain Visual Studio issues when switching between Debug and Release:
- After Switching, Close Visual Studio and Use the
Clean-obj-bin.batscript to clean allbin/andobj/folders.
- Debug builds target only
.NET 10for faster development. - Release builds target both
.NET 8,.Net 9and.NET 10, and will automatically generate a NuGet package inOutput/.
Contains:
- Attached properties
- Common
- Helpers
- Native methods
- Services
- Extensions
- Managers
Note
❌ No XAML or theme files in this project.
Contains all XAML-related functionality:
- Custom controls
- Styles, brushes, converters
- Win2D-based controls
-
Create the
.cscontrol file in one of these folders:Controls/: General controlsOthers/: If no specific category- A new folder (optional) if it includes multiple files
-
Add the XAML style to:
Themes/Styles/Controls/: General controlsThemes/Styles/Win2d/: Win2D-based controls
-
Create a Style with two parts:
- Default style with key:
<Style x:Key="DefaultMyControlStyle"
TargetType="local:MyControl">
<!-- Setters, Templates, etc. -->
</Style>- Override as implicit style:
<Style BasedOn="{StaticResource DefaultMyControlStyle}"
TargetType="local:MyControl" />- 🧱 Register the Default Style in Code
In your control's constructor, set the
DefaultStyleKey:
public MyControl()
{
this.DefaultStyleKey = typeof(MyControl);
}Warning
Do not include code-behind (x:Class) in any XAML files intended for Generic.xaml. Use ResourceDictionary only.
The files under Themes/Styles/** are automatically included in Generic.xaml by the build process.
Caution
Do not manually edit, and Avoid placing the implicit style directly in Generic.xaml it is auto-generated by the XAMLTools.MSBuild package.
Tip
These folders are automatically included in Generic.xaml via the XAMLTools.MSBuild NuGet package:
- Themes\Styles
- Controls\Ported
- A .NET Standard class library that supports WinUI, WPF, WinForms, etc.
- Uses a binary-only DLL (ContextMenuCustomHost.dll) due to licensing.
- Do not edit or remove this file.
- Add a new .xaml page in:
dev/DevWinUI.Gallery/Views/Pages/Use a subfolder based on category:
Features/
LandingPages/
Win2d/
Common/- Update the XAML:
<Page x:Class="DevWinUIGallery.Views.YourPage"
xmlns:dev="using:DevWinUI"
xmlns:local="using:DevWinUIGallery">- Update the code-behind namespace:
namespace DevWinUIGallery.Views;- Add a
<ControlExample>block inside the page like this:
<ScrollViewer>
<StackPanel Margin="10"
dev:PanelAttach.ChildrenTransitions="Default"
Spacing="10">
<local:ControlExample DocPage="yourcontrol" HeaderText="YourControl">
<local:ControlExample.Xaml>
<x:String>
<dev:YourControl Property="Value" />
</x:String>
</local:ControlExample.Xaml>
<dev:YourControl />
</local:ControlExample>
</StackPanel>
</ScrollViewer>Tip
📂 Browse other sample pages for examples.
- Add the sample entry to
Assets/NavViewMenu/AppData.json:
{
"UniqueId": "DevWinUIGallery.Views.YourPage",
"Title": "YourControl",
"Subtitle": "YourControl",
"IsNew": true,
"ImagePath": "ms-appx:///Assets/Fluent/Viewbox.png"
}- Rebuild the solution.
Important
🧹 Clean up any auto-added ItemGroup Removed/Included/... lines in the .csproj.
Versions are controlled centrally in Directory.Build.props with properties like:
<!-- Major Version -->
<LibraryMajorVersion>8</LibraryMajorVersion>
<!-- Minor Version -->
<DevWinUI_MinorVersion>4</DevWinUI_MinorVersion>
<DevWinUI_Base_MinorVersion>4</DevWinUI_Base_MinorVersion>
<DevWinUI_ContextMenu_MinorVersion>3</DevWinUI_ContextMenu_MinorVersion>
<DevWinUI_Gallery_MinorVersion>4</DevWinUI_Gallery_MinorVersion>
<!-- Patch Version -->
<DevWinUI_PatchVersion>1</DevWinUI_PatchVersion>
<DevWinUI_Base_PatchVersion>1</DevWinUI_Base_PatchVersion>
<DevWinUI_ContextMenu_PatchVersion>0</DevWinUI_ContextMenu_PatchVersion>
<DevWinUI_Gallery_PatchVersion>0</DevWinUI_Gallery_PatchVersion>
<!-- -Preview -->
<IsPreviewBuild>false</IsPreviewBuild>
<PreviewLabel>-Preview</PreviewLabel>It also defines:
- NuGet metadata
- Supported platforms
- Shared configuration settings
In DevWinUI, all code (regardless of folder depth or purpose) should use the root namespace:
namespace DevWinUI;In XAML, always declare:
xmlns:local="using:DevWinUI"Avoid deeper namespaces like DevWinUI.Controls, DevWinUI.Blah, etc.
All control and helper classes must be marked as partial to support Native AOT.
public partial class MyControl : Control
{
// ...
}Avoid using reflection-based logic, or any indirect type access. These break Native AOT compatibility.
- Do not include ItemGroup Removed/Included/... auto-generated lines in .csproj.
- Do not touch
Themes/Generic.xaml— it's generated. - Follow folder structure and naming conventions.
- Format all XAML using the provided styler configuration.
- Use Single
DevWinUInamespace. - Follow Native AOT recommendations
- Fork the repository
- Create a branch:
- Make your changes
- Commit with a descriptive message
- Push and create a pull request
Questions? Open an issue or contact @ghost1372.