Contributing to DevWinUI
May 4, 2026 ยท View on GitHub
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.
๐บ Video Tutorials
To get started quickly, watch these YouTube video tutorials:
โ๏ธ Build and Compile the Source
Tip
Please confirm that your development environment meets the requirements before compiling.
1. ๐ฅ๏ธ Visual Studio 2026
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.
2. ๐ ๏ธ SDKs
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
3. Installed the XAML Styler extension (Optional for Building, Required for Contribute):
Make sure your environment matches these requirements to avoid issues during compilation.
๐ฆ Repository Structure
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
๐ Code Style & Formatting
- 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.
๐งน Cleaning Build Artifacts
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 and Release Configuration
- 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/.
๐งฑ Project Details
๐ DevWinUI.Base (Core Library)
Contains:
- Attached properties
- Common
- Helpers
- Native methods
- Services
- Extensions
- Managers
Note
โ No XAML or theme files in this project.
๐ DevWinUI (Controls Library)
Contains all XAML-related functionality:
- Custom controls
- Styles, brushes, converters
- Win2D-based controls
โ Adding a New Control
-
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
๐ DevWinUI.ContextMenu
- 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.
๐ DevWinUI.Gallery (Sample App)
โ Add a New Sample Page
- 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.
๐ Project Versioning
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
๐ DevWinUI Namespace
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.
๐งผ Code Guidelines
โ๏ธ Partial Classes
All control and helper classes must be marked as partial to support Native AOT.
public partial class MyControl : Control
{
// ...
}
๐ซ Avoid Reflection
Avoid using reflection-based logic, or any indirect type access. These break Native AOT compatibility.
โ Notes
- 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
๐ค Ready to Contribute?
- Fork the repository
- Create a branch:
- Make your changes
- Commit with a descriptive message
- Push and create a pull request
Thank you for helping make DevWinUI better! ๐
Questions? Open an issue or contact @ghost1372.