Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
Snapshot grid structure info instead of modifying it in place
Browse files Browse the repository at this point in the history
Fixes #6247; Fixes #10470
  • Loading branch information
hartez committed Oct 28, 2020
1 parent b59bb76 commit 600db07
Show file tree
Hide file tree
Showing 2 changed files with 636 additions and 619 deletions.
16 changes: 5 additions & 11 deletions Xamarin.Forms.Core/Grid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,14 @@ internal override void ComputeConstraintForView(View view)

var result = LayoutConstraint.None;

if (_rows == null || _columns == null)
EnsureRowsColumnsInitialized();
// grab a snapshot of this grid's structure for computing the constraints
var structure = new GridStructure(this);

if (vOptions.Alignment == LayoutAlignment.Fill)
{
int row = GetRow(view);
int rowSpan = GetRowSpan(view);
List<RowDefinition> rowDefinitions = _rows;
List<RowDefinition> rowDefinitions = structure.Rows;

var canFix = true;

Expand All @@ -196,7 +196,7 @@ internal override void ComputeConstraintForView(View view)
{
int col = GetColumn(view);
int colSpan = GetColumnSpan(view);
List<ColumnDefinition> columnDefinitions = _columns;
List<ColumnDefinition> columnDefinitions = structure.Columns;

var canFix = true;

Expand Down Expand Up @@ -227,13 +227,7 @@ public void InvalidateMeasureInernalNonVirtual(InvalidationTrigger trigger)
{
InvalidateMeasureInternal(trigger);
}
internal override void InvalidateMeasureInternal(InvalidationTrigger trigger)
{
base.InvalidateMeasureInternal(trigger);
_columns = null;
_rows = null;
}


void OnDefinitionChanged(object sender, EventArgs args)
{
ComputeConstrainsForChildren();
Expand Down
Loading

0 comments on commit 600db07

Please sign in to comment.