0
votes

I'm using Xamarin forms PCL and deploying on android.

I have a listview that when has no results displays the string "Nothing to show" as a unique item of the list.

When this is done I also deactivate the items separation line because if I don't I have a silver grey line under the unique item.

Then, when I have results I reactivate the items separation line.

BUT ! When reactivating the line not all items have it !

For instance it can look like this :

item1
------------
item2

item3
-----------
item4
----------
item5

item6

As you can see there is no separator between item 2-3 and 5-6 for no reason at all.

All elements are added in a for loop. They are all strings.
The bug is random and can be between any items.

To show the separators I do :

myList.SeparatorVisibility = SeparatorVisibility.Default;

And to hide them :

myList.SeparatorVisibility = SeparatorVisibility.None;

Is this a bug on my end or from Xamarin forms ?
Any idears of how to fix this ?

2
Is this on an emulator? I've had this happen on an emulator before because the resolution was too small - cvanbeek
@cvanbeek Nope this is on an actual phone ! - Doctor
I allways choose to set the SeparatorVisibility to None and create my own separator with a BoxView inside the DataTemplate. - FabriBertani
Is this on the emulator or an actual device? - Steve Chadbourne

2 Answers

0
votes

I think you can set ListView's IsVisible property to false when items.Count() == 0 and set a Label "No items found" IsVisible property to true when items.Count() == 0

0
votes

This property is not meant to be set dynamically. As you can see here https://stackoverflow.com/a/6233491/202179, those changes on iOS are rendered only when cell is rendered again, which means that you would have to use ReloadData on the native table to make it consistent. As that method is not exposed in the ListView there is no way out of the box to do what you ask for.