SfListView referenced through a ContentView seems to have problems with item sizing

Hello everyone,

I'm currently facing a problem, while I was doing some tests with reloading the SfListView. It seems, that if you reference a ContentView which contains a SfListView the list has problems with showing the items in the correct size. It's hard to describe the problem, therefore I created a sample project, which shows what I mean.

Please have a look at this: SampleProject

The ContentPage "MainPage" contains the reference of a listview, which you can find in the ContentView "ListView". The ContentPage "ListViewPage" contains the ListView as directly implemented. The two pages update the listview through a while loop after 2,5 seconds. In the "ListViewPage" you see everything is fine. On the "MainPage" you can see that the items' size are nearly 0 (tested on an iPhone 5s simulator).

Maybe I'm doing something very wrong here or there is a bug. Any help would be appreciated!

Please ask if anything is unclear.

Update 11/26/2017:
If I call an InitializeComponent() right before I set the ItemsSource of the SfListView with the new values then the items are shown correctly. But that shouldn't be the right approach. Maybe this helps you in finding the problem.

Kind regards
Daniel

3 Replies

MK Muthu Kumaran Gnanavinayagam Syncfusion Team November 27, 2017 01:00 PM UTC

Hi Daniel, 
 
We have checked the reported query “SfListView height does not set properly when loaded in ContentView” and also referred the attached sample from our side. While loading the SfListView inside ContentPage, it acquires the size of the whole ContentPage. But when loaded inside ContentView, we need to mention the Height of SfListView inside the View. So you can set the parent element Height(which is StackLayout in your case) to SfListView’s HeightRequest as like below code example. 
 
Code Example[C#]: 
private void LoadData() 
{ 
  Debug.WriteLine(numberOfItems); 
  TestListview.ItemsSource = TestItemRepo.CreateItems(numberOfItems); 
 TestListview.HeightRequest = this.ParentView.Height; 
} 
 
For your assistance, we have modified your sample and attached the link below. 
 
 
Note: We have already considered it as an enhancement from our side and the date of implementation is tentative. 
 
Please let us know if you require further assistance. 
 
Regards, 
G.Muthu Kumaran. 



DC Daniel Cleemann November 27, 2017 04:12 PM UTC

Hi Muthu,

that solved my issue. Thanks a lot!

Kind regards
Daniel


MK Muthu Kumaran Gnanavinayagam Syncfusion Team November 28, 2017 04:00 AM UTC

Hi Daniel, 
 
Thanks for the update. 
 
Regards, 
G.Muthu Kumaran. 


Loader.
Up arrow icon