Browse Source

Merge pull request #8742 from Maruhl/master

Code refactored for better maintainability (Code from #8668)
pull/8749/head
Max Katz 4 years ago
committed by GitHub
parent
commit
ee1b110bfc
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 40
      src/Avalonia.Controls.DataGrid/DataGrid.cs

40
src/Avalonia.Controls.DataGrid/DataGrid.cs

@ -2172,34 +2172,18 @@ namespace Avalonia.Controls
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);
}
}
}
NotifyDataContextPropertyForAllRowCells(GetAllRows(), 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);
}
}
}
}
NotifyDataContextPropertyForAllRowCells(GetAllRows(), false);
}
/// <summary>
/// Raises the BeginningEdit event.
/// </summary>
@ -3197,6 +3181,20 @@ namespace Avalonia.Controls
}
}
private static void NotifyDataContextPropertyForAllRowCells(IEnumerable<DataGridRow> rowSource, bool arg2)
{
foreach (DataGridRow row in rowSource)
{
foreach (DataGridCell cell in row.Cells)
{
if (cell.Content is StyledElement cellContent)
{
DataContextProperty.Notifying?.Invoke(cellContent, arg2);
}
}
}
}
private void UpdateRowDetailsVisibilityMode(DataGridRowDetailsVisibilityMode newDetailsMode)
{
int itemCount = DataConnection.Count;

Loading…
Cancel
Save