listviewxamarinxamarin.formscustom-cell

Xamarin forms Custom Cell diplays only first row


I am newbie to Xamarin forms and I would like to create app useful for drivers. I am trying to create custom cell with multiple stacklayouts inside. But in listview there is only first row of my custom cell displayed. Here is my Custom cell code:

<ListView x:Name="ListViewRides">
<ListView.ItemTemplate>
  <DataTemplate>
    <ViewCell>
      <StackLayout Orientation="Vertical" Margin="15">
        <StackLayout Orientation="Horizontal">
          <Label x:Name="LabelLocationFrom" Text="{Binding PlaceFrom}" Margin="0, 0, 5,0"/>
          <Label Text="->"/>
          <Label x:Name="LabelLocationTo" Text="{Binding PlaceTo}" Margin="5, 0, 0, 0"/>
        </StackLayout>
        <StackLayout Orientation="Horizontal">
          <Label x:Name="LabelTimeFrom" Text="{Binding TimeFrom}" Margin="0, 0, 5,0"/>
          <Label Text="->"/>
          <Label x:Name="LabelTimeTo" Text="{Binding TimeTo}" Margin="5, 0, 0, 0"/>
        </StackLayout>
        <Label x:Name="LabelCustomer" Text="{Binding Customer}"></Label>
      </StackLayout>
    </ViewCell>
  </DataTemplate>
</ListView.ItemTemplate>

Here is the result in displayed in Simulator Result in simulator

I do not understand where I am making the mistake, Could someone please help me? For complete overview I am also adding the ViewModel Code:

public class RidesViewModel:Bindable
{
    public string PlaceFrom { get; set; }
    public string PlaceTo { get; set; }
    public DateTime TimeFrom { get; set; }
    public DateTime TimeTo { get; set; }
    public string Load { get; set; }
    public int Weight { get; set; }
    public string Note { get; set; }
    public string ContactPersonFrom { get; set; }
    public string ContactPersonTo { get; set; }
    public string Customer { get; set; }
    public string Trailer { get; set; }
    public bool IsReadyToShow { get; set; }
    public string RideState { get; set; }
}

Thank you for advices. I suppose that it is something obvious which I can't see right now.


Solution

  • You not being able to see it is probably due to the fact that it is out of view, but it is there.

    Set the RowHeight property of your ListView to a higher value to verify this.

    The RowHeight should be able to calculate when you set to -1 and set HasUnevenRows to true if I'm not mistaken. However that does not always work in my experience. To do make it work you will probably have to go about it with some custom renderers.