ListView.HasUnevenRows property is not working in Xamarin.Forms.iOS

680 Views Asked by At

If I set "ListView.hasUnevenRows = True", then listview's row height should be based on its item content. This is working in Android and iOS(in almost all the devices).

But in iPhone 12 (14.5), this property is not working which means row height is not set based on the item content.

Has anyone faced this before? I should asked this in Xamarin official forum but before that I just want to confirm whether any workaround is there or I have missed anything here

1

There are 1 best solutions below

3
Adrain On

I did a test on my side and it works fine, as you can see below,:

xmal:

<ListView x:Name="mylist" HasUnevenRows="True">
<ListView.ItemTemplate>
<DataTemplate>
  <ViewCell>
      <StackLayout>
          <Label Text="{Binding Name}"/>
      </StackLayout>
  </ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>

codebehind:

 public TestPage1()
    {
        InitializeComponent();
        List<People> peoples = new List<People> {
            new People {Name="111111111111111111111111111111111111111111111111111222" ,age=10},
            new People{Name="333333333333" ,age=20},
            new People{ Name="hahahahahaha" ,age=30}
        };
        mylist.ItemsSource = peoples;
        
    }

result

and here is a sample link you can test on your side: https://github.com/xamarin/xamarin-forms-samples/tree/main/WorkingWithListview/WorkingWithListview/Uneven