Browse Source

Increase GenerateElement performance

Use ability of the IRecyclingDataTemplate to speed up performance, when CellTemplate is an instance of DataTemplate type.
pull/9632/head
dif-sam 4 years ago
committed by GitHub
parent
commit
8b490152d4
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      src/Avalonia.Controls.DataGrid/DataGridTemplateColumn.cs

6
src/Avalonia.Controls.DataGrid/DataGridTemplateColumn.cs

@ -64,9 +64,11 @@ namespace Avalonia.Controls
protected override Control GenerateElement(DataGridCell cell, object dataItem) protected override Control GenerateElement(DataGridCell cell, object dataItem)
{ {
if(CellTemplate != null) if (CellTemplate != null)
{ {
return CellTemplate.Build(dataItem); return (CellTemplate is IRecyclingDataTemplate recyclingDataTemplate)
? recyclingDataTemplate.Build(dataItem, cell.Content as IControl)
: CellTemplate.Build(dataItem);
} }
if (Design.IsDesignMode) if (Design.IsDesignMode)
{ {

Loading…
Cancel
Save