Bodenberg.AppDimens.Sdps.WinUI 3.6.1

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

Bodenberg.AppDimens.Sdps.WinUI

📖 Documentation: Bodenberg.AppDimens.Sdps.WinUI guide · complete API reference · all AppDimens .NET packages

Responsive sizes for WinUI 3 (Windows App SDK). Write {sdps:Sdp Value=16} instead of 16 and your margins, buttons and text adapt to the window — and are re-applied automatically when the user resizes the window or moves it to a monitor with another scale.

Same engine as Bodenberg.AppDimens.Maui.Sdps (Android sdp/ssp parity), packaged for WinUI 3 with no .NET MAUI dependency.

Frameworks net8.0-windows10.0.19041.0, net9.0-…, net10.0-… (min. Windows 10 1809 / 17763)
Windows App SDK 1.6 or newer (your app keeps its own version)
License Apache-2.0

Table of contents

  1. How it works
  2. Step 1 — Install
  3. Step 2 — Initialize in App.OnLaunched
  4. Step 3 — Use it in XAML
  5. Step 4 — Use it in C#
  6. Complete example page
  7. Which function should I use?
  8. Bindings and x:Bind
  9. Troubleshooting
  10. Português (resumo)

How it works

  • Keep the numbers you already use (16 for padding, 14 for text…).
  • AppDimens treats them as sizes on a 300-unit-wide reference screen and scales them to the window.
  • WinUI units are device-independent (effective pixels), so the result is right at any display scale.
  • Values set with {sdps:...} in XAML are re-applied automatically when the window changes.

WinUI markup extensions need the property name: always write Value= → {sdps:Sdp Value=16}.


Step 1 — Install

dotnet add package Bodenberg.AppDimens.Sdps.WinUI

or Manage NuGet Packages… → search Bodenberg.AppDimens.Sdps.WinUI → Install.


Step 2 — Initialize in App.OnLaunched

Open App.xaml.cs and add one line after the window is created:

using AppDimens.Sdps.WinUI;

protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
{
    m_window = new MainWindow();
    AppDimensWinUI.Initialize(m_window);   // ← sizes now follow THIS window
    m_window.Activate();
}

Step 3 — Use it in XAML

  1. Add the namespace to the root element (Window, Page or UserControl):
xmlns:sdps="using:AppDimens.Sdps.WinUI"
  1. Replace fixed numbers:

<Button Width="120" Height="40" Margin="16" FontSize="14" Content="Save" />


<Button Width="{sdps:Sdp Value=120}"
        Height="{sdps:Hdp Value=40}"
        Margin="{sdps:Sdp Value=16}"
        FontSize="{sdps:Ssp Value=14}"
        Content="Save" />

Margin, Padding, CornerRadius and Grid row/column sizes are converted automatically.


Step 4 — Use it in C#

using AppDimens.Sdps.WinUI;   // 16.Sdp(), 14.Ssp() …

saveButton.Width   = 120.Sdp();
saveButton.Margin  = new Thickness(16.Sdp());
titleText.FontSize = 22.Ssp();

// values set from code: re-apply after a resize
AppDimensWinUI.Changed += (_, _) => titleText.FontSize = 22.Ssp();

Complete example page

<Page x:Class="MyApp.MainPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:sdps="using:AppDimens.Sdps.WinUI">

    <Grid Padding="{sdps:Sdp Value=16}" RowSpacing="{sdps:Sdp Value=8}">
        <Grid.RowDefinitions>
            <RowDefinition Height="{sdps:Hdp Value=56}" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <TextBlock Text="Dashboard" FontSize="{sdps:Ssp Value=22}" VerticalAlignment="Center" />

        <Border Grid.Row="1" CornerRadius="{sdps:Sdp Value=12}" Padding="{sdps:Sdp Value=16}"
                Background="{ThemeResource CardBackgroundFillColorDefaultBrush}">
            <StackPanel Spacing="{sdps:Sdp Value=8}">
                <TextBlock Text="Resize the window: every size is recalculated."
                           FontSize="{sdps:Ssp Value=14}" TextWrapping="Wrap" />
                <Button Content="Save" Width="{sdps:Sdp Value=120}" />
            </StackPanel>
        </Border>
    </Grid>
</Page>

Which function should I use?

I want to size… Use Example
Padding, margins, icons, cards — most cases Sdp {sdps:Sdp Value=16}
Things that follow the window height Hdp {sdps:Hdp Value=56}
Things that follow the window width Wdp {sdps:Wdp Value=200}
Text Ssp {sdps:Ssp Value=14}
Text by height / width Hsp / Wsp {sdps:Hsp Value=18}
Text ignoring the user font scale Sem {sdps:Sem Value=12}
Slightly bigger on very wide/tall windows add a: Sdpa, Sspa {sdps:Sdpa Value=16}
Fixed after startup (ignores resizes) add i: Sdpi, Sspi {sdps:Sdpi Value=16}

Extra options: Live=False (compute once) and As=Thickness|CornerRadius|GridLength|Double (force the type).


Bindings and x:Bind

<Page.Resources>
    <sdps:DimenConverter x:Key="Sdp" Function="Sdp" />
</Page.Resources>

<Border Width="{x:Bind ViewModel.CardWidth, Converter={StaticResource Sdp}}" />
<TextBlock FontSize="{x:Bind ViewModel.TitleSize, Converter={StaticResource Sdp}, ConverterParameter=Ssp}" />

Troubleshooting

Problem Fix
The type 'Sdp' was not found Use xmlns:sdps="using:AppDimens.Sdps.WinUI" and the Value= syntax.
Sizes don't follow the window Call AppDimensWinUI.Initialize(window) in OnLaunched, before Activate().
Values set in C# don't update Re-apply them in AppDimensWinUI.Changed.

Português (resumo)

  1. Instale: dotnet add package Bodenberg.AppDimens.Sdps.WinUI
  2. Em App.OnLaunched, depois de criar a janela: AppDimensWinUI.Initialize(m_window);
  3. No XAML: xmlns:sdps="using:AppDimens.Sdps.WinUI" e troque números por {sdps:Sdp Value=16} (tamanhos), {sdps:Ssp Value=14} (texto), {sdps:Hdp Value=56} (altura), {sdps:Wdp Value=200} (largura).
  4. Em C#: botao.Width = 120.Sdp(); — para atualizar no redimensionamento use AppDimensWinUI.Changed.

Links: Repository · WPF version · MAUI version

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

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.

Version Downloads Last Updated
3.6.1 91 10/12/2026