AppDimens.Net.Density
3.6.1
dotnet add package AppDimens.Net.Density --version 3.6.1
NuGet\Install-Package AppDimens.Net.Density -Version 3.6.1
<PackageReference Include="AppDimens.Net.Density" Version="3.6.1" />
<PackageVersion Include="AppDimens.Net.Density" Version="3.6.1" />
<PackageReference Include="AppDimens.Net.Density" />
paket add AppDimens.Net.Density --version 3.6.1
#r "nuget: AppDimens.Net.Density, 3.6.1"
#:package AppDimens.Net.Density@3.6.1
#addin nuget:?package=AppDimens.Net.Density&version=3.6.1
#tool nuget:?package=AppDimens.Net.Density&version=3.6.1
AppDimens.Net.Density
Density-aware scaling — multiplies by the display density (dpi ÷ 160), not by the window size.
Part of AppDimens for .NET (C# port of appdimens-kmp) · requires AppDimens.Net (installed automatically).
Works with .NET MAUI, WPF, Windows Forms, WinUI 3 and plain .NET (net8.0 / net9.0 / net10.0).
📖 Complete guide: AppDimens.Net.Density documentation · API reference: API.md
What it does
The Density strategy scales the value by the display density relative to 160 dpi (Android mdpi): 16.DSdp() is 16 at 160 dpi, 32 at 320 dpi and 48 at 480 dpi. It does not follow the window size — use it when an element should keep the same physical proportion across low- and high-density screens. On Windows the density is the monitor scale (100 % = 1.0, 150 % = 1.5).
16 with this strategy |
Phone 360×800 | Tablet 800×1280 | Desktop 1280×800 |
|---|---|---|---|
16.DSdp() |
16 | 16 | 16 |
16.DHdp() |
16 | 16 | 16 |
16.DWdp() |
16 | 16 | 16 |
16.Sdp() (core Scaled) |
19.2 | 42.7 | 42.7 |
Install
dotnet add package AppDimens.Net.Density
Use
- Initialize once for your UI framework: MAUI
AppDimensMaui.AttachWindow(window)· WPFAppDimensWpf.Initialize(this)· WinFormsAppDimensWinForms.Initialize(this)· WinUIAppDimensWinUI.Initialize(window). - Call the extensions:
using AppDimens.Net.Code.Density;
float padding = 16.DSdp(); // smaller side of the window
float header = 56.DHdp(); // height
float sidebar = 200.DWdp(); // width
float tall = 16.DSdpa(); // + aspect-ratio correction
float split = 16.DSdpi(); // ignores split-screen shrinking
With an explicit context: 16.DSdp(ctx), 16.DSdpPx(ctx), DimenDensity.DSdp(ctx, 16), 24.ToDensityDp(ctx, qualifier: DpQualifier.Width).
Português
dotnet add package AppDimens.Net.Density → inicialize a janela uma vez → using AppDimens.Net.Code.Density; → 16.DSdp(), 56.DHdp(), 200.DWdp().
Guia completo: https://github.com/bodenberg/appdimens-net-binding/blob/main/docs/AppDimens.Net.Density/README.md
Apache-2.0 — © Jean Bodenberg · Repository
| 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
- AppDimens.Net (>= 3.6.1)
-
net8.0
- AppDimens.Net (>= 3.6.1)
-
net9.0
- AppDimens.Net (>= 3.6.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on AppDimens.Net.Density:
| Package | Downloads |
|---|---|
|
AppDimens.Net.Sdk
AppDimens .NET meta-package ("BOM"): pulls the principal library plus every strategy module with a single reference. |
GitHub repositories
This package is not used by any popular GitHub repositories.