Reputation: 8562
I'm building an application in Xamarin Forms targeting iOS, Android and ideally also UWP, but that's not absolutely required. I have a page which will have three ListView controls. Each ListView is databound with the items coming from the database. I'd like each of them to size so that all items can be seen without scrolling the ListView. Instead the page should scroll. I've tried changing the page so that the lists are contained in a StackLayout instead of a Grid, and have also tried various combinations of setting the layout and views' VeriticalOptions to ExpandAndFill, but each takes up roughly a third of the screen making the lists larger than they need (for the first two, which only contain a few items) or too small (for the third, which may contain a number of rows).
How can I get the views to resize and show all of their items?
Upvotes: 1
Views: 1506
Reputation: 571
You need to set a height on the ListView in order to achieve a fixed height. If the ItemSource for the list is dynamic I would suggest using a single list with grouping. Some details that might help you can be found on this related topic here.
If your list is static then just set the ListView.Height = <appropriate size>
for each listview
Upvotes: 1
Reputation: 255
Having a ListView inside a ScrollView is not recommended, i'd suggest to bind your three lists into a single ListView and then using TemplateSelectors and/or grouping to achieve the look and feel you are looking for.
Upvotes: 1