From fb350701ffbf19b820bcbc68065ab64eb92fc237 Mon Sep 17 00:00:00 2001 From: Yoyo Date: Sun, 28 Jun 2026 17:09:02 +0800 Subject: [PATCH] Fix DataGridBoundColumn null path bindings --- src/Avalonia.Controls.DataGrid/DataGridBoundColumn.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Avalonia.Controls.DataGrid/DataGridBoundColumn.cs b/src/Avalonia.Controls.DataGrid/DataGridBoundColumn.cs index 56fe791..c6ee880 100644 --- a/src/Avalonia.Controls.DataGrid/DataGridBoundColumn.cs +++ b/src/Avalonia.Controls.DataGrid/DataGridBoundColumn.cs @@ -58,7 +58,7 @@ public virtual BindingBase Binding throw new InvalidOperationException("DataGridColumn doesn't support BindingMode.OneWayToSource. Use BindingMode.TwoWay instead."); } - var path = compiled.Path.ToString(); + var path = compiled.Path?.ToString(); if (!string.IsNullOrEmpty(path) && compiled.Mode == BindingMode.Default) { compiled.Mode = BindingMode.TwoWay; @@ -76,7 +76,7 @@ public virtual BindingBase Binding throw new InvalidOperationException("DataGridColumn doesn't support BindingMode.OneWayToSource. Use BindingMode.TwoWay instead."); } - var path = reflection.Path.ToString(); + var path = reflection.Path; if (!string.IsNullOrEmpty(path) && reflection.Mode == BindingMode.Default) { reflection.Mode = BindingMode.TwoWay; @@ -140,7 +140,7 @@ internal void SetHeaderFromBinding() if (OwningGrid != null && OwningGrid.DataConnection.DataType != null && Header == null && Binding != null && Binding is BindingBase binding) { - var path = (binding as Binding)?.Path ?? (binding as CompiledBindingExtension)?.Path.ToString(); + var path = (binding as Binding)?.Path ?? (binding as CompiledBindingExtension)?.Path?.ToString(); if (!string.IsNullOrWhiteSpace(path)) { var header = OwningGrid.DataConnection.DataType.GetDisplayName(path);