Browse Source

Merge pull request #8668 from aldelaro5/dataGrid-notify-cells-dataContext-updates

Implement DataContext update notifications on the DataGrid
pull/8742/head
Max Katz 4 years ago
committed by GitHub
parent
commit
63351a06a2
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 32
      src/Avalonia.Controls.DataGrid/DataGrid.cs

32
src/Avalonia.Controls.DataGrid/DataGrid.cs

@ -2167,6 +2167,38 @@ namespace Avalonia.Controls
return desiredSize;
}
/// <inheritdoc/>
protected override void OnDataContextBeginUpdate()
{
base.OnDataContextBeginUpdate();
foreach (DataGridRow row in GetAllRows())
{
foreach (DataGridCell cell in row.Cells)
{
if (cell.Content is StyledElement)
{
DataContextProperty.Notifying?.Invoke((IAvaloniaObject)cell.Content, true);
}
}
}
}
/// <inheritdoc/>
protected override void OnDataContextEndUpdate()
{
base.OnDataContextEndUpdate();
foreach (DataGridRow row in GetAllRows())
{
foreach (DataGridCell cell in row.Cells)
{
if (cell.Content is StyledElement)
{
DataContextProperty.Notifying?.Invoke((IAvaloniaObject)cell.Content, false);
}
}
}
}
/// <summary>
/// Raises the BeginningEdit event.

Loading…
Cancel
Save