AppDimens.Net
3.6.0
dotnet add package AppDimens.Net --version 3.6.0
NuGet\Install-Package AppDimens.Net -Version 3.6.0
<PackageReference Include="AppDimens.Net" Version="3.6.0" />
<PackageVersion Include="AppDimens.Net" Version="3.6.0" />
<PackageReference Include="AppDimens.Net" />
paket add AppDimens.Net --version 3.6.0
#r "nuget: AppDimens.Net, 3.6.0"
#:package AppDimens.Net@3.6.0
#addin nuget:?package=AppDimens.Net&version=3.6.0
#tool nuget:?package=AppDimens.Net&version=3.6.0
<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.
</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 anIAppDimensContextexplicitly or useFakeAppDimensContext.
π§ 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
kvalues 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 | Versions 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. |
-
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 |