diff --git a/src/Avalonia.Controls.TreeDataGrid/Primitives/TreeDataGridTextCell.cs b/src/Avalonia.Controls.TreeDataGrid/Primitives/TreeDataGridTextCell.cs index b56d09f5..510b35fe 100644 --- a/src/Avalonia.Controls.TreeDataGrid/Primitives/TreeDataGridTextCell.cs +++ b/src/Avalonia.Controls.TreeDataGrid/Primitives/TreeDataGridTextCell.cs @@ -33,6 +33,7 @@ public class TreeDataGridTextCell : TreeDataGridCell private string? _value; private TextBox? _edit; + private bool _modelValueChanging; private TextTrimming _textTrimming = TextTrimming.CharacterEllipsis; private TextWrapping _textWrapping = TextWrapping.NoWrap; private TextAlignment _textAlignment = TextAlignment.Left; @@ -54,7 +55,7 @@ public string? Value get => _value; set { - if (SetAndRaise(ValueProperty, ref _value, value) && Model is ITextCell cell) + if (SetAndRaise(ValueProperty, ref _value, value) && Model is ITextCell cell && !_modelValueChanging) cell.Text = _value; } } @@ -109,7 +110,17 @@ protected override void OnModelPropertyChanged(object? sender, PropertyChangedEv base.OnModelPropertyChanged(sender, e); if (e.PropertyName == nameof(ITextCell.Value)) - Value = Model?.Value?.ToString(); + { + try + { + _modelValueChanging = true; + Value = Model?.Value?.ToString(); + } + finally + { + _modelValueChanging = false; + } + } } } }