Closed RemcoDEV closed 2 years ago
@RemcoDEV Can you post a small reproduction project? Or at least paste in an example of your ItemTemplate, EmptyView, and the code you're using to set up your ItemsSource?
@RemcoDEV I encounter the same bug. A possible workaround is to add IsVisible
to the content of your EmptyView
. E.g. <StackLayout IsVisible="{Binding DocumentGroups, Converter={StaticResource ListIsNullOrEmptyConverter}}">
. Here I have used the converter ListIsNullOrEmptyConverter
from the XamarinCommunityToolkit. The converter is also easy to implement yourself if you don't want the dependency.
@hartez If it is any help I can report that this bug only occurs when the CollectionView
is a child of a TabbedPage
.
@RemcoDEV I encounter the same bug. A possible workaround is to add
IsVisible
to the content of yourEmptyView
. E.g.<StackLayout IsVisible="{Binding DocumentGroups, Converter={StaticResource ListIsNullOrEmptyConverter}}">
. Here I have used the converterListIsNullOrEmptyConverter
from the XamarinCommunityToolkit. The converter is also easy to implement yourself if you don't want the dependency.@hartez If it is any help I can report that this bug only occurs when the
CollectionView
is a child of aTabbedPage
.
Tnx man!
Same issue for me. Draws both Empty and Item View. Not using Tabbed Page. Xamarin test team should really use rest service to test with some async calls. I am sure all this works when you have data hardcoded into the view model.
Just updated to 5.0.0.2012 from 5.0.0.1931. There are other issue in 5.0.0.1931 that breaks CollectionView binding when visibility state is initially false. At least that seems to be fixed in 5.0.0.2012.
Hello all, can someone please upload a small reproduction of this issue so we can investigate it further?!
thanks.
Same problem here.
@marcojak can you please upload a small reproduction of the issue?
@hartez @rmarinho @Redth , I have added a small repro project. There is some gross code incoming so brace yourselves.
In this particular case I was able to replicate it by doing what I do in my prod app, which took me down a rabbit hold where I found some jank code. Fixing my jank fixes the issue, however I think the underlying issue may still happen in other circumstances.
Problem is only present when for me CollectionView
is inside a CarouselView
. If I replace the CarouselView
with a CollectionView
the problem goes away. The other bit of jank in the code is I am creating an ObservableCollection
on my MainPage
which is populated by loading a local file/web request/etc, and a reference of this is passed to MyCollectionView
class.
Within MyCollectionView
I keep a reference of the ObservableCollection
(Data = data;
) AFTER I set the BindingContext
.
My workaround is to fix the jank and move this line to before I set the BindingContext
and then the problem goes away. Another possible solution I havn't tried would be setting ItemsSource
of MyCollectionView
from the MainPage
.
So yeah, there is some things here that I shouldn't be doing, but its still putting CollectionView
in an odd state where it both has and does not have data.
@RemcoDEV @beeradmore, a PR for this is open now (#14603), would you be able to grab the NuGet as described here and let us know if this fixes this issue? That will greatly speed up the review process.
Besides verifying if this particular issue is fixed also be sure to check other scenarios in the same area to make sure that this fix doesn't accidentally has side-effects 🙂
Thanks!
Hi @jfversluis ,
Just tested. It still does not work on the latest XF 5.0.0.2125 (pull request of Javier is from before that release date). The pull request of Javier does not change any logic, it are just tests. It can be approved without causing any side effects :).
Regards, Remco
Sorry about that Remco! Just noticed a PR and added that message in the hope you could test it :D
Seems we have some work to do here still, thanks!
I suspect something in here has to do with it: https://github.com/xamarin/Xamarin.Forms/pull/13678
Hey @beeradmoore @RemcoDEV, a PR (#15122) for this is open now, would you be able to grab the NuGet as described here and let us know if this fixes this issue? That will greatly speed up the review process. Make sure to take the exact version as attached to this PR.
Besides verifying if this particular issue is fixed also be sure to check other scenarios in the same area to make sure that this fix doesn't accidentally has side-effects 🙂
Thanks!
Hi @jfversluis . It seems to work as intended. No side effects found. Thank you!
@jfversluis , my above repro is in a weird state where trying to use it (either with the XF it has, updated, or updated to the PR version) where attempting to scroll it crashes it. That repro also has some weird things happening in it so it may be because of that.
I tried it in our production app and I didn't notice any new problems. However in its pre-PR-nuget state we also no longer were experiencing this issue.
I however do still have header/footer showing when CollectionView is empty and displaying the correct EmptyView. I have a feeling that this isn't a bug and instead a design choice. Changing that behaviour will impact anyone using header/footer + EmptyView so its probably best left untouched (unless we want to add some new HideHeaderOnEmpty HideFooterOnEmpty properties to CollectionView in MAUI).
Perfect, thanks so much for taking the time to verify and provide me with this input! Looks like I'll be merging this for now and look at the other mentioned things separately.
Description
CollectionView iOS draws both EmptyView and Items/ItemTemplate. The itemtemplate UI becomes unresponsive, because the emptyview is drawn over it.
Steps to Reproduce
Expected Behavior
Only draw the emptyview when the itemssource is empty.
Actual Behavior
Both the emptyview and the items/itemtemplates are drawn.
Basic Information
Environment
Visual Studio 2019 / Windows 10
Build Logs
--
Screenshots
'Nothing to display' is the emptyview. This example is a grouped collectionview, but it also happens to non-grouped collectionviews.
Reproduction Link
--
Workaround
Reconstructing the page sometimes works. Refreshing does not work. Something definitely goes wrong when constructing the page.