Nested `ItemsView` Items stays highlighted on PointerOver
Describe the bug
When nesting an ItemsView control inside another ItemsViews Item (or ItemsRepeater) the Items inside stay highlighted after hovering on them. This happens with all the new major versions and 1.7 experimental as well.
Steps to reproduce the bug
<ItemsRepeater ItemsSource="{x:Bind Categories, Mode=OneWay}">
<ItemsRepeater.ItemTemplate>
<DataTemplate x:DataType="local:Category">
<ItemContainer>
<StackPanel DataContext="{x:Bind}">
<TextBlock Text="{x:Bind Label}"
HorizontalAlignment="Center"
FontSize="20"
Margin="0,10,0,10" />
<ItemsView ItemsSource="{x:Bind}">
<ItemsView.ItemTemplate>
<DataTemplate x:DataType="local:Item">
<ItemContainer>
<TextBlock Text="{x:Bind Label}"
HorizontalAlignment="Center" />
</ItemContainer>
</DataTemplate>
</ItemsView.ItemTemplate>
</ItemsView>
</StackPanel>
</ItemContainer>
</DataTemplate>
</ItemsRepeater.ItemTemplate>
</ItemsRepeater>
NestedItemsViewHighlighting.zip
Expected behavior
No response
Screenshots
https://github.com/user-attachments/assets/2d207629-1ae1-4d33-98d3-0bec89863deb
NuGet package version
WinUI 3 - Windows App SDK 1.6.3: 1.6.241114003
Windows version
Windows Insider Build (xxxxx)
Additional context
Related to https://github.com/unoplatform/uno/issues/19180
I did a little investigation with the source and the root cause seems to be happening in ItemsContainer ProcessPointerOver. When using a mouse the ResetIsMousePointerOver doesn't seem to be properly executed when the ItemsView is nested as the isPointerOver isn't changed during the method causing the UpdateVisualState call at the end to be skipped.
A potential hotfix would be to remove this check: https://github.com/microsoft/microsoft-ui-xaml/blob/ffe33f9b7d0e9f5a2ca3330d0ce329f09dff092b/src/controls/dev/ItemContainer/ItemContainer.cpp#L301 This change could resolve the issue, albeit with a minor performance impact.
can you please take a loot at this https://github.com/microsoft/microsoft-ui-xaml/issues/10319 @joelleigh @mrlacey @MartyIX @morning4coffe-dev
I also see the same or a similar issue with a normal (not nested) ItemsView when pressing the mouse button while hovering over an item and then moving the mouse outside the item's bounds before releasing the mouse button again