Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem clearing VisualStates of collection items in a CollectionView, when the collection employs a DataTemplate generated with a DataTemplateSelector #22541

Closed
axa88 opened this issue May 21, 2024 · 2 comments
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

Comments

@axa88
Copy link

axa88 commented May 21, 2024

Description

A problem clearing VisualStates of collection items in a CollectionView, when the collection employs a DataTemplate generated with a DataTemplateSelector

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.

image

2 Clear the Collection (Collection.Clear)
3 Repopulate the collection with NEW item(s).
4 Observe the VisualState lingering from the OLD item(s)

image

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's ItemTemplage:

    Items.CollectionChanged += (sender, notifyCollectionChangedEventArgs) =>
    {
        if (notifyCollectionChangedEventArgs.Action == NotifyCollectionChangedAction.Reset)
        {
	        SelectedItem = null;
	        SelectedItems = null;
    
	        ItemTemplate = null;
	        ItemTemplate = dataTemplateSelector;
        }
    };

This was also the work around to a somewhat related bug #21252

Relevant log output

No response

@axa88 axa88 added the t/bug Something isn't working label May 21, 2024
Copy link
Contributor

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@PureWeen PureWeen added s/needs-repro Attach a solution or code which reproduces the issue platform/windows 🪟 area-controls-collectionview CollectionView, CarouselView, IndicatorView labels May 21, 2024
@axa88
Copy link
Author

axa88 commented May 22, 2024

@

Honestly why wait 7 days. Just close it now as you guys apparently have no inclination to accept it for what it is.

There are dozens of bugs filed screaming that VisualStates are broken, and nothing is getting fixed, so i don't imagine this one more bug is going to help anything. Just close it. Last bug I bother filing about it

@dotnet-policy-service dotnet-policy-service bot added s/needs-attention Issue has more information and needs another look and removed s/needs-repro Attach a solution or code which reproduces the issue labels May 22, 2024
@PureWeen PureWeen closed this as not planned Won't fix, can't repro, duplicate, stale May 23, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jun 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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
Projects
None yet
Development

No branches or pull requests

2 participants