From 424ddb0463476ec7bd0cfcd398300dd92b5d47b1 Mon Sep 17 00:00:00 2001 From: Lubomir Tetak Date: Thu, 4 Nov 2021 09:31:00 +0100 Subject: [PATCH] DataGridColumn - fix LayoutRoundedWidth with DPI scaling applied --- src/Avalonia.Controls.DataGrid/DataGridColumn.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Avalonia.Controls.DataGrid/DataGridColumn.cs b/src/Avalonia.Controls.DataGrid/DataGridColumn.cs index 5499257171..943b5d597e 100644 --- a/src/Avalonia.Controls.DataGrid/DataGridColumn.cs +++ b/src/Avalonia.Controls.DataGrid/DataGridColumn.cs @@ -13,6 +13,7 @@ using System.ComponentModel; using System.Linq; using System.Diagnostics; using Avalonia.Controls.Utils; +using Avalonia.Layout; using Avalonia.Markup.Xaml.MarkupExtensions; namespace Avalonia.Controls @@ -834,9 +835,9 @@ namespace Avalonia.Controls { if (OwningGrid != null && OwningGrid.UseLayoutRounding) { - double roundedLeftEdge = Math.Floor(leftEdge + 0.5); - double roundedRightEdge = Math.Floor(leftEdge + ActualWidth + 0.5); - LayoutRoundedWidth = roundedRightEdge - roundedLeftEdge; + var scale = LayoutHelper.GetLayoutScale(HeaderCell); + var roundSize = LayoutHelper.RoundLayoutSize(new Size(leftEdge + ActualWidth, 1), scale, scale); + LayoutRoundedWidth = roundSize.Width - leftEdge; } else {