From e27abdd1ff971df78db0c122f9c24bd734652fb0 Mon Sep 17 00:00:00 2001 From: Alex Strelnik Date: Tue, 7 May 2024 10:51:24 +0300 Subject: [PATCH] Subscribe to model changes in TreeDataGridCheckBoxCell --- .../Primitives/TreeDataGridCheckBoxCell.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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 bool IsThreeState } 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)