Closed billhenn closed 1 year ago
probably not using IsSet
but checking if it's equal to the set one? Something like this:
if (itemContainerTheme is not null &&
!container.IsSet(ThemeProperty) &&
+ itemContainerTheme != container.Theme &&
StyledElement.GetStyleKey(container) == itemContainerTheme.TargetType)
can you test this in your sample?
can you test this in your sample?
@timunie Sure... from testing, if we pull out and replace the IsSet
line with the one you suggested, it works for us.
if (itemContainerTheme is not null &&
itemContainerTheme != container.Theme &&
StyledElement.GetStyleKey(container) == itemContainerTheme.TargetType)
Describe the bug The
ItemsControl.ItemContainerTheme
property is important because it allows us to define how the containers of items should appear in relation to theControlTheme
for theItemsControl
itself.There is an
ItemsControl
bug right now where if you use a container control that would have been generated as the "item" itself, any future changes toItemContainerTheme
are not reapplied to existing containers.To Reproduce Use this code in an app and click the button at the bottom. The button will change the
TabControl
theme, which should in turn also update theTabItem
theme used. But that doesn't happen.XAML:
C#:
Before clicking the button, you'll see this at startup:
After you click the button, you'll see this, which as you can see does not update the item theme:
Expected behavior When clicking the button in the code above, the UI should look like this instead:
Cause The problem is this
if
condition inItemsControl.PrepareItemContainer
. When the control is first displayed, it assigns eachcontainer.Theme
ok but then if we change theItemContainerTheme
later, while it does seem to re-execute this logic, the newcontainer.Theme
is never applied since that!container.IsSet(ThemeProperty)
check fails.If that
!container.IsSet(ThemeProperty)
line is commented out, the expected behavior is achieved. I'm not sure the ideal fix for this (taking that line out or something else), but we do need to get it working to support control themes properly.Environment Windows 11 running Avalonia v11.0.4.