Browse Source

Grid fixes (#15516)

* Fixed ShowGridLines = false crash

Fixed "System.InvalidOperationException: 'The control GridLinesRenderer already has a visual parent Grid (Name = grid) while trying to add it as a child of Grid (Name = grid).'" when set ShowGridLines = false and resize.

* Fixed grid lines renderer (fixes ShowGridLines binding)

When changing ShowGridLines property GridLinesRenderer is not updating (create/remove/set bounds). Need to call InvalidateArrange -> ArrangeOverride -> EnsureGridLinesRenderer.
pull/15496/head
zii-dmg 2 years ago
committed by GitHub
parent
commit
f0777a42b9
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 4
      src/Avalonia.Controls/Grid.cs

4
src/Avalonia.Controls/Grid.cs

@ -2325,7 +2325,7 @@ namespace Avalonia.Controls
if ((!ShowGridLines) && (_gridLinesRenderer != null))
{
VisualChildren.Add(_gridLinesRenderer);
VisualChildren.Remove(_gridLinesRenderer);
_gridLinesRenderer = null;
}
@ -2357,7 +2357,7 @@ namespace Avalonia.Controls
if (grid._extData != null // trivial grid is 1 by 1. there is no grid lines anyway
&& grid.ListenToNotifications)
{
grid.InvalidateVisual();
grid.InvalidateArrange();
}
grid.SetFlags((bool)e.NewValue!, Flags.ShowGridLinesPropertyValue);

Loading…
Cancel
Save