Repository: AvaloniaUI/Avalonia
File: src/Avalonia.Controls/Primitives/UniformGrid.cs (C#)

Code before:
                (availableSize.Width - (_columns - 1) * ColumnSpacing) / _columns,
                (availableSize.Height - (_rows - 1) * RowSpacing) / _rows);

            foreach (var child in Children)
            {
                child.Measure(childAvailableSize);

                if (child.DesiredSize.Width > maxWidth)
                {
                    maxWidth = child.DesiredSize.Width;
                }

                if (child.DesiredSize.Height > maxHeight)
                {
                    maxHeight = child.DesiredSize.Height;
                }
            }

            // If layout rounding is enabled, round the measured per-cell unit size (maxWidth/maxHeight).
            // We round the measured max sizes instead of the childAvailableSize to avoid changing the input
            // used for children.Measure(...) which could change how children measure themselves.
            if (UseLayoutRounding)
            {
                if (!double.IsInfinity(maxWidth) && !double.IsNaN(maxWidth))
                {
                    maxWidth = Math.Round(maxWidth);
                }

                if (!double.IsInfinity(maxHeight) && !double.IsNaN(maxHeight))
                {
                    maxHeight = Math.Round(maxHeight);
                }
            }

            var totalWidth = maxWidth * _columns + ColumnSpacing * (_columns - 1);
            var totalHeight = maxHeight * _rows + RowSpacing * (_rows - 1);

            totalWidth = Math.Max(totalWidth, 0);
            totalHeight = Math.Max(totalHeight, 0);

            return new Size(totalWidth, totalHeight);
        }

        protected override Size ArrangeOverride(Size finalSize)
        {
            var x = FirstColumn;
            var y = 0;

            var columnSpacing = ColumnSpacing;
            var rowSpacing = RowSpacing;


Review comment (refactor):
This doesn't seem right, we normally use `LayoutHelper.RoundLayoutXxx` methods with a scale to adjust for the current DPI.

Code after:

            var childAvailableSize = new Size(
                (availableSize.Width - (_columns - 1) * ColumnSpacing) / _columns,
                (availableSize.Height - (_rows - 1) * RowSpacing) / _rows);

            foreach (var child in Children)
            {
                child.Measure(childAvailableSize);

                if (child.DesiredSize.Width > maxWidth)
                {
                    maxWidth = child.DesiredSize.Width;
                }

                if (child.DesiredSize.Height > maxHeight)
                {
                    maxHeight = child.DesiredSize.Height;
                }
            }

            if (UseLayoutRounding)
            {
                var scale = LayoutHelper.GetLayoutScale(this);
                maxWidth = LayoutHelper.RoundLayoutValue(maxWidth, scale);
                maxHeight = LayoutHelper.RoundLayoutValue(maxHeight, scale);
            }

            var totalWidth = maxWidth * _columns + ColumnSpacing * (_columns - 1);
            var totalHeight = maxHeight * _rows + RowSpacing * (_rows - 1);

            totalWidth = Math.Max(totalWidth, 0);
            totalHeight = Math.Max(totalHeight, 0);

            return new Size(totalWidth, totalHeight);
        }

        protected override Size ArrangeOverride(Size finalSize)
        {
            var x = FirstColumn;
            var y = 0;

            var columnSpacing = ColumnSpacing;
            var rowSpacing = RowSpacing;

            var width = Math.Max((finalSize.Width - (_columns - 1) * columnSpacing) / _columns, 0);
            var height = Math.Max((finalSize.Height - (_rows - 1) * rowSpacing) / _rows, 0);

            // If layout rounding is enabled, round the per-cell unit size to integral device units.
            if (UseLayoutRounding)
            {
                var scale = LayoutHelper.GetLayoutScale(this);