Display List of Objects in a ListView - Xamarin.forms [duplicate]

0

The question is as follows, I want to display a list of objects in my View using a ListView. Currently the code looks like this:

<ListView x:Name="listaDestinos" ItemsSource="{Binding ListaDestinos}">
        <ListView.Header>
            <StackLayout BackgroundColor="Gray" WidthRequest="100"  HeightRequest="40">
                <Label Text="Paradas" TextColor="White" FontSize="18" VerticalOptions="CenterAndExpand" HorizontalOptions="Center"></Label>
            </StackLayout>
        </ListView.Header>
        <ListView.ItemTemplate>
            <DataTemplate>
                <ViewCell>
                    <ViewCell.View>
                        <StackLayout WidthRequest="400" HeightRequest="100">
                            <Label Text="{Binding Linha}" FontSize="15"></Label>
                            <Label Text="{Binding Nome}" FontSize="15"></Label>
                            <Label Text="{Binding Origem}" FontSize="15" ></Label>
                            <Label Text="{Binding Destino}" FontSize="15"></Label>
                            <Label Text="{Binding Municipio}" FontSize="15"></Label>
                        </StackLayout>
                    </ViewCell.View>
                </ViewCell>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>

In this way, only the object related to "Line" and "Name" appears on the screen, the other three (Origin, Destination and Municipality) do not appear. I want to know how do I display all five fields, that is, I want to know how to increase the size of the display space for these objects . Thanks in advance to anyone who can help. regards.

    
asked by anonymous 19.06.2018 / 20:26

1 answer

0

Add in your listview HasUnevenRows="True"

<ListView x:Name="listaDestinos" ItemsSource="{Binding ListaDestinos}" HasUnevenRows="True">

From a searched before you find it easy A question equal to your

    
19.06.2018 / 20:31