
When items are quickly added or removed from AnimatedStackPanel, and there is "await" between adding and removing, UI elements of individual items stop being interactive.
AnimatedStackPanel is used as ItemsPanelTemplate of ItemsControl. ItemsControl's ItemsSource is bound to ObservableCollection, items of which are inserted and removed by one frequently. Source code for sample app and the video of how the problem reproduces are here:
https://drive.google.com/drive/folders/1FJWi0Lq0Xfs9pzdaFSfnNLiM-SFnIe1w?usp=sharing
In this test app single ObservableCollection is used for 2 ItemsControls, the only difference between which is that the first one uses AnimatedStackPanel, when the second one doesn't:
<ItemsControl Grid.Row="1" Grid.Column="0"
ItemsSource="{Binding Path=Items}"
ItemTemplate="{StaticResource ItemTemplate}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<views1:AnimatedStackPanel />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
<ItemsControl Grid.Row="1" Grid.Column="1"
ItemsSource="{Binding Path=Items}"
ItemTemplate="{StaticResource ItemTemplate}" />
So, the first one misbehaves while the second one is always fine.
ItemTemplate is a textbox which has a trigger on MouseOver which makes background yellow - this is how we can keep track of whether the UI is "interactive" or not. "Replace" button removes one item from the collection and then creates the new one and inserts it to where the removed item was. "Set Random" button sets random value to the item of the collection, so we can see whether the UI is redrawn. "Quick Replace All" button performs "Replace" for each item in cycle.
Sometimes it reproduces after the first click on "Quick Replace All", sometimes - not. In the video I clicked several times quickly. It also can reproduce when clicking individual "Replace" buttons one by one manually, especially when in reverse order. The problem doesn't reproduce if there is no "await" between remove and insert, or if the delay between remove and insert is longer than duration of animation.
Initially found on .NET 7, but on .NET 6 it's the same.