AppDimens.Net 3.6.0

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

<div align="center">

πŸ“ AppDimens.Net

Responsive dimensions for .NET MAUI β€” scaled dp/sp with snapshot caching and allocation-free fast lanes.

The principal module: core engine, Scaled strategy (Sdp/Sdpa/Hdp/Wdp), inverters, facilitators, builder, ambient context and cache.

NuGet License .NET Platforms

</div>


✨ Why AppDimens?

Fixed dp values don't scale across phones, foldables, tablets and desktops. AppDimens scales your dimensions from a screen qualifier (smallest-width, height or width), with bit-a-bit parity to the Kotlin appdimens-kmp library, an event-driven resize watcher, and a snapshot-partitioned cache that makes hot-path lookups allocation-free.

float pad = 16.Sdp();   // scales with smallest-width β€” the classic SDP lane
float h   = 48.Hdp();   // scales with height axis
float w   = 24.Wdp();   // scales with width axis
float sp  = 16.Ssp();   // text size, font-scale aware

πŸ“¦ Installation

dotnet add package AppDimens.Net
Targets net8.0 Β· net9.0 Β· net10.0
Dependencies none
License Apache-2.0

πŸš€ Getting started

Attach a window once (MAUI) β€” before creating any page:

using AppDimens.Net.Maui.Platform;

protected override Window CreateWindow(IActivationState? state)
{
    var window = new Window();
    AppDimensMaui.AttachWindow(window);          // ambient context + cache + resize watcher
    window.Page = new NavigationPage(new MainPage());
    return window;
}

Parameterless extensions resolve through AppDimensAmbient.Require(). Outside MAUI (unit tests, design time, Blazor), pass an IAppDimensContext explicitly or use FakeAppDimensContext.

🧭 The Scaled strategy

scaled = value Γ— screenDp(qualifier) Γ· 300            (base design width: 300 dp)
Extension family Meaning
v.Sdp() Β· v.Sdpa() smallest-width lane (+ aspect-ratio adjustment)
v.Hdp() Β· v.Wdp() height / width axis lanes
v.Sdpi() … ia variants ignore multi-window constraints
v.SdpPx() … pixel result in one call

Inverters β€” axis-swap rules for rotation

Extension Rule
v.SdpPh(raw) portrait β†’ height qualifier
v.SdpLw(raw) / v.SdpLh(raw) landscape β†’ width / height
v.SdpPw(raw) portrait β†’ width
v.HdpLw…, v.Wdp… same rules on other lanes

Facilitators β€” conditional values without if-chains

16.SdpRotate(24, Orientation.Landscape);      // 24 when landscape, else scaled 16
16.SdpMode(20, UiModeType.Foldable);          // UI-mode aware
16.SdpQualifier(DpQualifier.SmallWidth, 600f, 28);  // β‰₯600 sw β†’ 28
16.SdpScreen(UiModeType.Normal, DpQualifier.SmallWidth, 700f, 32);
// …and *Plain variants that take pre-scaled branches (no re-scaling).

Builder β€” declarative screens

float size = 18.ScaledDp()
    .AspectRatio()
    .Screen(DpQualifier.SmallWidth, 600f, 26f)     // tablet
    .Screen(Orientation.Landscape, 22f)            // landscape override
    .Screen(UiModeType.Foldable, 30f)
    .Sdp();

Priority: qualifier+orientation β†’ mode-only β†’ qualifier-only β†’ orientation-only.

Generic kernel

Full control in a single entry point (also used by every satellite module):

float v = baseValue.ToDynamicScaledDp(ctx, qualifier, inverter, ignoreMultiWindows, applyAspectRatio, k);

⚑ Performance

  • Fast lanes (DimenCache.ResolveSdpDp/Hdp/Wdp(+Px)): allocation-free, bitwise-equal to the full cached path.
  • Snapshot-partitioned cache: configuration changes invalidate automatically via the event watcher β€” no manual clearing.
  • Custom sensitivity k values bypass caching by design.

πŸ§ͺ Testing support

FakeAppDimensContext ships in this package: mutable configuration + NotifyChange() to drive watchers deterministically.

πŸ“š Full package family

Package Strategy
AppDimens.Net (this) Scaled core + inverters + facilitators
AppDimens.Net.Percent percentage of screen dimension
AppDimens.Net.Power power-law curve
AppDimens.Net.Auto auto-balanced scaling
AppDimens.Net.Logarithmic logarithmic growth
AppDimens.Net.Fluid fluid interpolation
AppDimens.Net.Interpolated interpolated curve
AppDimens.Net.Diagonal screen diagonal basis
AppDimens.Net.Perimeter screen perimeter basis
AppDimens.Net.Fill fill-proportional
AppDimens.Net.Fit priority-driven fit builder
AppDimens.Net.Density density-aware scaling
AppDimens.Net.Resize auto-resize text/squares
AppDimens.Net.Units mm/cm/inch conversions
AppDimens.Net.Maui window attach + XAML markup
AppDimens.Net.Sdk meta-package (everything)

Apache-2.0 β€” Β© Jean Bodenberg Β· Repository Β· Documentation Β· Formulas are bit-a-bit ports of appdimens-kmp

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages (15)

Showing the top 5 NuGet packages that depend on AppDimens.Net:

Package Downloads
AppDimens.Net.Percent

AppDimens .NET β€” Percent scaling strategy module.

AppDimens.Net.Auto

AppDimens .NET β€” Auto scaling strategy module.

AppDimens.Net.Perimeter

AppDimens .NET β€” Perimeter scaling strategy module.

AppDimens.Net.Fluid

AppDimens .NET β€” Fluid scaling strategy module.

AppDimens.Net.Interpolated

AppDimens .NET β€” Interpolated scaling strategy module.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.6.0 345 8/23/2026