UserExtensions.Wpfx 0.1.0-alpha.13

This is a prerelease version of UserExtensions.Wpfx.
dotnet add package UserExtensions.Wpfx --version 0.1.0-alpha.13
                    
NuGet\Install-Package UserExtensions.Wpfx -Version 0.1.0-alpha.13
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="UserExtensions.Wpfx" Version="0.1.0-alpha.13" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="UserExtensions.Wpfx" Version="0.1.0-alpha.13" />
                    
Directory.Packages.props
<PackageReference Include="UserExtensions.Wpfx" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add UserExtensions.Wpfx --version 0.1.0-alpha.13
                    
#r "nuget: UserExtensions.Wpfx, 0.1.0-alpha.13"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package UserExtensions.Wpfx@0.1.0-alpha.13
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=UserExtensions.Wpfx&version=0.1.0-alpha.13&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=UserExtensions.Wpfx&version=0.1.0-alpha.13&prerelease
                    
Install as a Cake Tool

WPFX: code-first WPF, no XAML

Alpha release: WPFX is actively evolving. Feedback and experimentation are welcome.

WPFX is a lightweight, code-first library for building WPF UIs entirely in C#. No XAML.

Navigate your UI design as a collapsible UIElement tree directly in C# code.

Visual Studio showing a collapsed WPFX UI tree in C#

WPFX embraces a declarative, tree-oriented composition style inspired by modern UI frameworks such as Flutter, while keeping configuration in familiar C# code and building directly on top of WPF.

WPFX is intentionally lightweight — the library is contained in a single source file.

Build familiar WPF controls and supporting types using X helper methods:

WPF type Static helper method
StackPanel Wpfx.StackPanelX()
Grid Wpfx.GridX()
Border Wpfx.BorderX()
Button Wpfx.ButtonX()
Slider Wpfx.SliderX()
TextBox Wpfx.TextBoxX()
Thickness Wpfx.ThicknessX()
CornerRadius Wpfx.CornerRadiusX()
Binding Wpfx.BindingX()

Key Features

  • Pure C# layout — no .xaml files required
  • Declarative, tree-oriented UI composition
  • Natural parent/child composition using named child and children arguments
  • Modern C# collection expressions for clean UI tree definitions
  • Direct configuration of native WPF controls through the configure lambda
  • Works with existing WPF concepts including data binding, commands, events, MVVM and dependency injection

Design Principles

WPFX is designed around a few simple principles.

1. Keep the UI tree readable

The structure of the UI should be immediately obvious from the source code.

WPFX reduces visual noise by replacing repeated new expressions with X helper methods and taking advantage of modern C# features such as collection expressions.

The goal is for the code to read like a tree, similar to the structure of a JSON document, making parent/child relationships easy to follow.

2. Configure native WPF controls directly

Every X helper method creates a standard WPF object.

The optional configure lambda provides direct access to that object, allowing standard WPF properties, bindings, commands and events to be configured without introducing another abstraction layer.

3. Keep the UI in one place

WPFX encourages defining the entire visual tree inside a dedicated Build() method.

This provides a single, easily identifiable location for the application's UI, while allowing constructors, helper methods, event handlers and application logic to remain separate.

4. Write UI logic where it naturally belongs

Controls can be configured where they are declared, allowing the UI to be written in a natural top-to-bottom order.

WPFX encourages writing UI logic directly alongside the control it belongs to, following the natural flow of the visual tree. This keeps related code together and reduces the need to jump between XAML and code-behind or between distant sections of the same file.


Requirements

  • Windows
  • .NET 10 SDK (or later)
  • WPF

Getting Started

Choose whichever installation method best suits your project.

Install the latest release of UserExtensions.Wpfx.

dotnet add package UserExtensions.Wpfx

Option 2 — Copy the source file

WPFX is intentionally lightweight.

If you prefer not to take a package dependency, simply copy Wpfx.cs directly into your project. The library is contained in a single source file, making it easy to inspect and modify if desired.

Global using

Add a GlobalUsings.cs file to your project with the following content:

global using static UserExtensions.Wpfx;

This makes the X helper methods available directly throughout your project, without needing the Wpfx static class prefix.


Code Example

Program.cs
using System.Windows;

namespace Demo_01_Simple;

public static class Program
{
    [STAThread]
    public static void Main()
    {
        var app = new Application();

        var win = new MainWindow();

        app.Run(win);
    }
}
MainWindow.cs
using System.Windows;
using System.Windows.Controls;

namespace Demo_01_Simple;

public class MainWindow : Window
{
    private int _count = 0;
    private TextBlock? _txtInfo;

    public MainWindow()
    {
        Title = "Demo 01 Simple";
        WindowStartupLocation = WindowStartupLocation.CenterScreen;
        Width = 600;
        Height = 400;
        Content = Build();
    }

    private UIElement Build()
    {
        return StackPanelX(
            children: [
                ButtonX(
                    configure: x => {
                        x.Content = "Update";
                        x.Margin = ThicknessX(10);
                        x.Padding = ThicknessX(10);
                        x.HorizontalAlignment = HorizontalAlignment.Left;
                        x.VerticalAlignment = VerticalAlignment.Top;
                        
                        x.Click += (s, e) => {
                            _count++;
                            _txtInfo?.Text = $"Count: {_count}";
                        };
                    }
                ),
                TextBlockX(
                    configure: x => {
                        _txtInfo = x;
                        x.Margin = ThicknessX(10);
                        x.Text = $"Count: {_count}";
                    }
                )
            ]
        );
    }
}
Product Compatible and additional computed target framework versions.
.NET net10.0-windows7.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0-windows7.0

    • No dependencies.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on UserExtensions.Wpfx:

Package Downloads
WpfxCustomControls.LedClockControl

LED clock custom control, built entirely in C# with WPFX code-first framework

WpfxCustomControls.ClockControl

Lookless clock custom control, built entirely in C# with WPFX code-first framework

WpfxCustomControls.DrawerWindow

DrawerWindow custom control, built entirely in C# with WPFX code-first framework

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0-alpha.13 48 9/27/2026
0.1.0-alpha.12 84 9/12/2026
0.1.0-alpha.11 78 9/5/2026
0.1.0-alpha.10 88 8/26/2026
0.1.0-alpha.9 97 8/16/2026
0.1.0-alpha.8 79 8/6/2026
0.1.0-alpha.7 75 8/5/2026
0.1.0-alpha.6 73 8/2/2026
0.1.0-alpha.5 70 7/23/2026
0.1.0-alpha.4 75 7/21/2026
0.1.0-alpha.3 69 7/18/2026
0.1.0-alpha.2 65 7/18/2026
0.1.0-alpha.1 73 7/13/2026