How to make ListView NOT fill entire height of page

I have a StackLayout (Vertical) with 2 ListViews. I want each ListView to only occupy the vertical space it needs to occupy (that is, only take up the vertical space required by the sum of its childrens' heights). How can I make this happen? No matter what combination of LayoutOptions I set, the ListViews insist on each taking up half the vertical height of the page.

In fact, even just a single ListView inside a StackLayout is problematic. Take the following:

< StackLayout VerticalOptions="Start" BackgroundColor="Yellow" >
< Button Text="This is a button" / >
< Label Text="This is a label" / >
< ListView VerticalOptions="..." >
...
< /ListView >
< /StackLayout >

That ListView will occupy the entire height of the app that it can, no matter what LayoutOptions I set. But that's not what I want. If you remove the ListView, you'll see that the Yellow StackLayout is only as tall as it needs to be in order to contain the button and the label. That's what I want, but I want the ListView in there as well. If the ListView has only say, 3 children and only takes up 200 vertical units, then that's how tall the ListView should be. How can I make this happen?

Posts

Sign In or Register to comment.