diff --git a/src/Avalonia.Controls.TreeDataGrid/Primitives/TreeDataGridCheckBoxCell.cs b/src/Avalonia.Controls.TreeDataGrid/Primitives/TreeDataGridCheckBoxCell.cs index ad2a66d0..b6b1dea6 100644 --- a/src/Avalonia.Controls.TreeDataGrid/Primitives/TreeDataGridCheckBoxCell.cs +++ b/src/Avalonia.Controls.TreeDataGrid/Primitives/TreeDataGridCheckBoxCell.cs @@ -1,4 +1,5 @@ using System; +using System.ComponentModel; using Avalonia.Controls.Models.TreeDataGrid; using Avalonia.Controls.Selection; using Avalonia.Input; @@ -70,6 +71,21 @@ public override void Realize( } base.Realize(factory, selection, model, columnIndex, rowIndex); + SubscribeToModelChanges(); + } + + public override void Unrealize() + { + UnsubscribeFromModelChanges(); + base.Unrealize(); + } + + protected override void OnModelPropertyChanged(object? sender, PropertyChangedEventArgs e) + { + base.OnModelPropertyChanged(sender, e); + + if (e.PropertyName == nameof(CheckBoxCell.Value) && Model is CheckBoxCell checkBoxCell) + Value = checkBoxCell.Value; } protected override void OnPointerPressed(PointerPressedEventArgs e)