Skip to content

Commit

Permalink
perf: Make Grid.RowDefinitions and ColumnDefinitions lazy initial…
Browse files Browse the repository at this point in the history
…ized
  • Loading branch information
jeromelaban committed May 19, 2021
1 parent e8afc69 commit feaad83
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions src/Uno.UI/UI/Xaml/Controls/Grid/Grid.Definitions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,33 @@ partial class Grid
{
public Grid()
{
var rowDefinitions = new RowDefinitionCollection(this);
rowDefinitions.CollectionChanged += (snd, evt) => InvalidateDefinitions();

var columnDefinitions = new ColumnDefinitionCollection(this);
columnDefinitions.CollectionChanged += (snd, evt) => InvalidateDefinitions();
}

m_pRowDefinitions = rowDefinitions;
m_pColumnDefinitions = columnDefinitions;
public RowDefinitionCollection RowDefinitions
{
get
{
if(m_pRowDefinitions == null)
{
m_pRowDefinitions = new RowDefinitionCollection(this);
m_pRowDefinitions.CollectionChanged += (snd, evt) => InvalidateDefinitions();
}
return m_pRowDefinitions;
}
}

public RowDefinitionCollection RowDefinitions => m_pRowDefinitions;
public ColumnDefinitionCollection ColumnDefinitions
{
get
{

public ColumnDefinitionCollection ColumnDefinitions => m_pColumnDefinitions;
if (m_pColumnDefinitions == null)
{
m_pColumnDefinitions = new ColumnDefinitionCollection(this);
m_pColumnDefinitions.CollectionChanged += (snd, evt) => InvalidateDefinitions();
}
return m_pColumnDefinitions;
}
}
}
}

0 comments on commit feaad83

Please sign in to comment.