Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

How to set variable height in a ListView?

$
0
0

I have a list of images and I want to display them so that the width of each image fits the entire screen, while preserving the aspect ratio. I'm using a list view like the following:

    <ListView x:Name="imageListView">
        <ListView.ItemTemplate>
          <DataTemplate>
            <ViewCell>
              <ViewCell.View>
                <Image Source="{Binding .}" HorizontalOptions="FillAndExpand" />
              </ViewCell.View>
            </ViewCell>
          </DataTemplate>
        </ListView.ItemTemplate>
      </ListView>

However, the images still show up with a height of 40, since the ListView sets an equal height for the entire table. I'm currently thinking of writing a custom ListView renderer which extends the default renderer, but I'm not sure which methods I should override (or if it's doable at all). Can anyone point me in the right direction?


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>