AppDimens.Net.Wpf 3.6.1

dotnet add package AppDimens.Net.Wpf --version 3.6.1
                    
NuGet\Install-Package AppDimens.Net.Wpf -Version 3.6.1
                    
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="AppDimens.Net.Wpf" Version="3.6.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AppDimens.Net.Wpf" Version="3.6.1" />
                    
Directory.Packages.props
<PackageReference Include="AppDimens.Net.Wpf" />
                    
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 AppDimens.Net.Wpf --version 3.6.1
                    
#r "nuget: AppDimens.Net.Wpf, 3.6.1"
                    
#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 AppDimens.Net.Wpf@3.6.1
                    
#: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=AppDimens.Net.Wpf&version=3.6.1
                    
Install as a Cake Addin
#tool nuget:?package=AppDimens.Net.Wpf&version=3.6.1
                    
Install as a Cake Tool

AppDimens.Net.Wpf

📖 Documentation: AppDimens.Net.Wpf guide · complete API reference · all AppDimens .NET packages

WPF integration for AppDimens.Net — the pure C# port of AppDimens KMP. Sizes written as {ad:Sdp 16} (or 16.Sdp() in C#) follow the window size and the monitor DPI, and XAML values update live while the window is resized.

Includes the scaled (Sdp, Hdp, Wdp, Ssp…), fluid (FSdp…) and percent (PSdp…, SpaceW, SpaceH) strategies out of the box.

Frameworks net8.0-windows, net9.0-windows, net10.0-windows (+ net11.0-windows with SDK 11)
Depends on AppDimens.Net, AppDimens.Net.Fluid, AppDimens.Net.Percent (installed automatically)

Step 1 — Install

dotnet add package AppDimens.Net.Wpf

Step 2 — Initialize (one line)

using System.Windows;
using AppDimens.Net.Wpf;

public partial class MainWindow : Window
{
    public MainWindow()
    {
        AppDimensWpf.Initialize(this);   // ← must run before InitializeComponent()
        InitializeComponent();
    }
}

Step 3 — XAML

<Window ...
        xmlns:ad="clr-namespace:AppDimens.Net.Wpf;assembly=AppDimens.Net.Wpf">

    <StackPanel Margin="{ad:Sdp 16}">
        <TextBlock Text="Hello" FontSize="{ad:Ssp 22}" />
        <Button Content="Save" Width="{ad:Sdp 120}" Height="{ad:Hdp 40}" Padding="{ad:Sdp 8}" />
        <Border Width="{ad:SpaceW 50}" Height="{ad:FSdp 80}" CornerRadius="{ad:Sdp 12}" Background="#EEE" />
    </StackPanel>
</Window>
  • Margin, Padding, CornerRadius, GridLength are converted automatically.
  • {ad:SpaceW 50} = 50 % of the window width; {ad:FSdp 80} = fluid scaling (grows slower on huge screens).

Step 4 — C#

using AppDimens.Net.Code.Scaled;   // Sdp, Hdp, Wdp, Ssp …
using AppDimens.Net.Code.Fluid;    // FSdp, FHdp …
using AppDimens.Net.Code.Percent;  // PSdp, SpaceWDp …
using AppDimens.Net.Wpf;           // AppDimensWpf

saveButton.Width  = 120.Sdp();
titleText.FontSize = 22.Ssp();
banner.Height     = 80.FSdp();

// re-apply code-behind values after resizes
AppDimensWpf.Changed += (_, _) => titleText.FontSize = 22.Ssp();

Which function?

Need Function XAML
Most sizes (padding, icons, buttons) Sdp {ad:Sdp 16}
Follow window height / width Hdp / Wdp {ad:Hdp 56}
Text Ssp {ad:Ssp 14}
Text ignoring the font-scale setting Sem / Hem / Wem {ad:Sem 12}
Grows more gently on very large windows FSdp, FHdp, FWdp {ad:FSdp 24}
Percent-based scaling PSdp, PHdp, PWdp {ad:PSdp 24}
Literal % of the window SpaceW / SpaceH {ad:SpaceW 50}
Aspect-ratio curve / ignore multi-window suffix a / i {ad:Sdpa 16}

41 functions are available; see the DimenFunction enum. Options: Live=False, As=Thickness|CornerRadius|GridLength|Double.

Bindings

<Window.Resources>
    <ad:DimenConverter x:Key="Dimen" Function="Sdp" />
</Window.Resources>
<Border Width="{Binding CardWidth, Converter={StaticResource Dimen}}" />
<TextBlock FontSize="{Binding TitleSize, Converter={StaticResource Dimen}, ConverterParameter=Ssp}" />

Troubleshooting

Problem Fix
AppDimens ambient context is not initialized in C# Call AppDimensWpf.Initialize(this) first (XAML initializes automatically with the screen size).
Code-behind values don't update Re-apply them in AppDimensWpf.Changed.

Português (resumo)

dotnet add package AppDimens.Net.Wpf → no construtor da janela AppDimensWpf.Initialize(this); antes de InitializeComponent() → no XAML xmlns:ad="clr-namespace:AppDimens.Net.Wpf;assembly=AppDimens.Net.Wpf" e use {ad:Sdp 16}, {ad:Ssp 14}, {ad:SpaceW 50} (50 % da largura). Em C#: 120.Sdp() com using AppDimens.Net.Code.Scaled;.

More: AppDimens.Net core · Repository

Product Compatible and additional computed target framework versions.
.NET net8.0-windows7.0 is compatible.  net9.0-windows was computed.  net9.0-windows7.0 is compatible.  net10.0-windows was computed.  net10.0-windows7.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.6.1 103 10/12/2026