Problem clearing VisualStates of collection items in a CollectionView, when the collection employs a DataTemplate generated with a DataTemplateSelector #22541
Labels
area-controls-collectionview
CollectionView, CarouselView, IndicatorView
platform/windows 🪟
s/needs-attention
Issue has more information and needs another look
t/bug
Something isn't working
Description
A problem clearing
VisualStates
of collection items in aCollectionView
, when the collection employs aDataTemplate
generated with aDataTemplateSelector
Meaning if an item in the collection has a VisualState applied, and then the Collection is cleared, when repopulating the collection, it is possible that the previous now cleared collection's VisualState will improperly be applied to the now new item collection.
Steps to Reproduce
1 Populate a CollectionView and select an item in the collection to apply some
VisualState
to the item.2 Clear the Collection (Collection.Clear)
3 Repopulate the collection with NEW item(s).
4 Observe the VisualState lingering from the OLD item(s)
Link to public reproduction project repository
No response
Version with bug
8.0.40 SR5
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
Windows
Affected platform versions
Windows 10.0.19041
Did you find any workaround?
In response to the aformentioned Collection (Collection.Clear) request, it is possible to subscribe to the subsequent CollectionChange event, to nullify and the reapply (the same)
DataTemplateselector
to the CollectionView'sItemTemplage
:This was also the work around to a somewhat related bug #21252
Relevant log output
No response
The text was updated successfully, but these errors were encountered: