From 1dc19f16278d22530aa2b82f6f70ef6d2fb0cef6 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Wed, 14 Jun 2023 15:53:53 +0200 Subject: [PATCH] Checking _operation for null isn't enough. Instead check if `UpdateCount` is not 0 to allow recursive setting of `Source`. I have a vague feeling that this isn't actually the correct solution, and that more issues are going to arise around this scenario but for now I'm unable to create a failing test so let's go with the simple solution for now. Fixes #11617 --- src/Avalonia.Controls/Selection/SelectionModel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.Controls/Selection/SelectionModel.cs b/src/Avalonia.Controls/Selection/SelectionModel.cs index 68bad598d0..69bed2550e 100644 --- a/src/Avalonia.Controls/Selection/SelectionModel.cs +++ b/src/Avalonia.Controls/Selection/SelectionModel.cs @@ -277,7 +277,7 @@ namespace Avalonia.Controls.Selection { if (base.Source != value) { - if (_operation is not null) + if (_operation?.UpdateCount > 0) { throw new InvalidOperationException("Cannot change source while update is in progress."); }