Browse Source

Invalidate measure when showing a control.

But not when hiding it.
Steven Kirk 3 years ago
parent
commit
ddf266d9ae
1 changed files with 8 additions and 0 deletions
  1. 8 0
      src/Avalonia.Base/Layout/Layoutable.cs

+ 8 - 0
src/Avalonia.Base/Layout/Layoutable.cs

@@ -797,7 +797,15 @@ namespace Avalonia.Layout
             if (change.Property == IsVisibleProperty)
             {
                 DesiredSize = default;
+
+                // All changes to visibility cause the parent element to be notified.
                 this.GetVisualParent<ILayoutable>()?.ChildDesiredSizeChanged(this);
+
+                // We only invalidate outselves when visibility is changed to true.
+                if (change.GetNewValue<bool>())
+                {
+                    InvalidateMeasure();
+                }
             }
         }