Browse Source

Handle changing ItemContainerTheme properly.

Previously only handled the case where the `ItemContainerTheme` was changing from null -> non-null.

Fixes #12620
pull/12630/head
Steven Kirk 3 years ago
parent
commit
754bdd4220
  1. 8
      src/Avalonia.Controls/ItemsControl.cs

8
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;

Loading…
Cancel
Save