View List of Objects in a Listview - Xamarin.Forms

Asked

Viewed 117 times

0

The doubt is the following, I want to display a list of objects in my View using a Listview. Currently the code is 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>

So that this on the screen appears only the object related to the "Line" and "Name", the other three (Origin, Destination and Municipality) do not appear. I want to know how to appear all five fields, IE, I want to know how to increase the size of space for viewing these objects. From now on I thank anyone who can help. attentively.

1 answer

0

Add in your listview HasUnevenRows="True"

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

Of a researched before that finds easy A question like yours

  • I appreciate your reply, and I really should have looked it up before.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.