From 6a0a0f92ac41bdec87c76bcbe2c0856bdafe6ffa Mon Sep 17 00:00:00 2001 From: BobLd <38405645+BobLd@users.noreply.github.com> Date: Sat, 9 Nov 2024 13:03:57 +0000 Subject: [PATCH] Ensure VirtualizingStackPanel correct element size estimate and fix #17460 --- src/Avalonia.Controls/VirtualizingStackPanel.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Avalonia.Controls/VirtualizingStackPanel.cs b/src/Avalonia.Controls/VirtualizingStackPanel.cs index b3d61a9b643..f84582ce6bd 100644 --- a/src/Avalonia.Controls/VirtualizingStackPanel.cs +++ b/src/Avalonia.Controls/VirtualizingStackPanel.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Collections.Specialized; using System.Diagnostics; -using System.Drawing; using System.Linq; using Avalonia.Controls.Primitives; using Avalonia.Controls.Utils; @@ -164,6 +163,9 @@ protected override Size MeasureOverride(Size availableSize) _realizedElements ??= new(); _measureElements ??= new(); + // We need to set the lastEstimatedElementSizeU before calling CalculateDesiredSize() + _ = EstimateElementSizeU(); + // We handle horizontal and vertical layouts here so X and Y are abstracted to: // - Horizontal layouts: U = horizontal, V = vertical // - Vertical layouts: U = vertical, V = horizontal