Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug] CollectionView does not change from EmptyViewDataTemplate to NonEmptyViewDataTemplate through data template selector from version Xamarin.Forms 4.5 #10831

Closed
poliahrameshkumar opened this issue May 23, 2020 · 7 comments

Comments

@poliahrameshkumar
Copy link

Description

We use CollectionView where till the values load, we show Setting up loading indicator. This indicator is present in EmptyViewDataTemplate. For both EmptyView and NonEmptyView DataTemplates we use data template selector. This works in Xamarin.Forms 4.3 version but in 4.5 and 4.6 this is not working. Even after CollectionView ItemsSource is not empty, still EmptyViewDataTemplate only is present in UI and it is not changing to the required DataTemplate even after the ItemsSource becomes nonempty.

Steps to Reproduce

  1. Create EmptyViewDataTemplate and NonEmptyViewDataTemplate as part of CollectionView with Xamarin.Forms version 4.5 or above
  2. Make EmptyViewDataTemplate display first and add values to CollectionView after sometime
  3. You can see the DataTemplate is not changing from EmptyView to NonEmptyViewDataTemplate

Expected Behavior

DataTemplate should change from EmptyView to NonEmptyViewDataTemplate

Actual Behaviour

DataTemplate is not changing from EmptyView to NonEmptyViewDataTemplate

Basic Information

  • Version with issue: Xamarin.Forms 4.5 and above (Haven't checked 4.4)
  • Last known good version: Xamarin.Forms 4.3
  • IDE: Visual Studio for Mac
  • Platform Target Frameworks:
    • iOS: 11.4
    • Android:
    • UWP:
  • Android Support Library Version:
  • Nuget Packages: Xamarin.Forms 4.5
  • Affected Devices: iPad

Screenshots

Reproduction Link

Workaround

@poliahrameshkumar poliahrameshkumar added s/unverified New report that has yet to be verified t/bug 🐛 labels May 23, 2020
@poliahrameshkumar poliahrameshkumar changed the title [Bug] CollectionView does not change to EmptyViewDataTemplate to NonEmptyViewDataTemplate through data template selector from version Xamarin.Forms 4.5 [Bug] CollectionView does not change from EmptyViewDataTemplate to NonEmptyViewDataTemplate through data template selector from version Xamarin.Forms 4.5 May 23, 2020
@pauldipietro pauldipietro added this to New in Triage May 23, 2020
@samhouts samhouts added this to Backlog in CollectionView May 26, 2020
@samhouts
Copy link
Member

Can you please attach a small project that demonstrates this issue? Thanks!

@samhouts samhouts added 4.5.0 regression on 4.5.0 i/regression labels May 26, 2020
@jsuarezruiz jsuarezruiz moved this from New to Needs Info in Triage Jun 2, 2020
@samhouts samhouts moved this from Needs Info to New in Triage Jun 2, 2020
@jsuarezruiz
Copy link
Contributor

@poliahrameshkumar Could you share a small project that demonstrates the issue?. If not, don't worry, but I would like to know how do you validate the validation you use in the DataTemplateSelector to change from one template to other one (just to replicate the same case).

@jsuarezruiz jsuarezruiz moved this from New to Needs Info in Triage Jun 4, 2020
@poliahrameshkumar
Copy link
Author

@jsuarezruiz It is simple. Make the EmptyViewDataTemplate visible by keeping the item source of CollectionView empty. Then you can load few values to CollectionView and check if the DataTemplate changes from EmptyViewDataTemplate to NonEmptyViewDataTemplate. If required, I can create sample tomorrow and attach here.

@samhouts samhouts moved this from Needs Info to New in Triage Jun 4, 2020
@jsuarezruiz
Copy link
Contributor

@poliahrameshkumar I created a sample:
Issue10831.zip

Is working fine on Android and in iOS is failing the first time, when adding successive items, it works correctly.
Captura de pantalla 2020-06-05 a las 10 08 51
So, can reproduce the issue, thanks for the feedback.

@jsuarezruiz jsuarezruiz added e/3 🕒 3 and removed s/unverified New report that has yet to be verified labels Jun 5, 2020
@jsuarezruiz jsuarezruiz moved this from New to Ready For Work in Triage Jun 5, 2020
@samhouts samhouts removed this from Ready For Work in Triage Jun 5, 2020
@poliahrameshkumar
Copy link
Author

poliahrameshkumar commented Jun 5, 2020

@jsuarezrui I did little research with both my current app and your sample app.

The issue in sample app starts appearing from Xamarin.Forms 4.3.0.991250. But this issue is not reproducible with latest Xamarin.Forms 4.6.0.847.

The issue in my current app starts only from Xamarin.Forms 4.4.0.991477 and it is still reproducible with latest Xamarin.Forms 4.6.0.847.

So, the issue I am facing is more related to EmptyView and EmptyViewTemplate of CollectionView. The issue sample you created is more specific to ItemTemplate change.

Both might be related to each other, but still they differ. We can get to know that by the above observation. Anyhow, Thank you for the sample which gave me a workaround to fix the issue.

The issue for both is same of DataTemplate not changing when the first element added for ItemsSource or first assignment happened for ItemsSource.

Temporarily adding an element and removing element for the second time is a workaround.

@samhouts samhouts added this to the 4.5.0 milestone Jun 17, 2020
@samhouts samhouts removed this from the 4.5.0 milestone Jul 8, 2020
@samhouts samhouts added this to the 5.0.0 milestone Aug 13, 2020
@samhouts samhouts added this to To do in vNext+1 (5.0.0) Aug 13, 2020
@samhouts samhouts removed this from the 5.0.0 milestone Nov 2, 2020
@hartez
Copy link
Contributor

hartez commented Feb 6, 2021

There's a small possibility #13678 fixes this issue.

@hartez hartez moved this from Review Backlog to Backlog in CollectionView Feb 6, 2021
@poliahrameshkumar
Copy link
Author

This issue has got fixed in Xamarin.Forms 5.0. Thank you for the support.

CollectionView automation moved this from Backlog to Done Feb 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Development

No branches or pull requests

4 participants