From 754bdd4220e91cae5c76466cc98d88c41c761075 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Tue, 22 Aug 2023 13:44:00 +0200 Subject: [PATCH] Handle changing ItemContainerTheme properly. Previously only handled the case where the `ItemContainerTheme` was changing from null -> non-null. Fixes #12620 --- src/Avalonia.Controls/ItemsControl.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Avalonia.Controls/ItemsControl.cs b/src/Avalonia.Controls/ItemsControl.cs index 83aa88a7b6..47b943ed2e 100644 --- a/src/Avalonia.Controls/ItemsControl.cs +++ b/src/Avalonia.Controls/ItemsControl.cs @@ -665,12 +665,10 @@ namespace Avalonia.Controls { var itemContainerTheme = ItemContainerTheme; - if (itemContainerTheme is not null && - !container.IsSet(ThemeProperty) && - StyledElement.GetStyleKey(container) == itemContainerTheme.TargetType) - { + if (itemContainerTheme is null) + container.Theme = null; + else if (GetStyleKey(container) == itemContainerTheme.TargetType) container.Theme = itemContainerTheme; - } if (item is not Control) container.DataContext = item;