在设计中,ListView需要嵌套到StackLayout中,但是ListView会出现一片空白部分,如何移除空白部分?
问题如图所示:
Xaml代码:
1 <?xml version="1.0" encoding="utf-8" ?> 2 <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 3 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 4 x:Class="XFPractice.Pages.ContactsPage"> 5 6 <StackLayout Orientation="Vertical"> 7 8 <ListView x:Name="MyListView" 9 ItemsSource="{Binding Items}" 10 ItemTapped="Handle_ItemTapped" 11 HasUnevenRows="True" 12 VerticalOptions="Start" 13 CachingStrategy="RecycleElement"> 14 15 <ListView.ItemTemplate> 16 <DataTemplate> 17 <TextCell Height="36" Text="{Binding .}" /> 18 </DataTemplate> 19 </ListView.ItemTemplate> 20 </ListView> 21 22 <StackLayout Grid.Row="1" Orientation="Vertical" VerticalOptions="FillAndExpand"> 23 <Button Text="按钮一" Margin="12,0"/> 24 <Button Text="按钮二" Margin="12,0"/> 25 </StackLayout> 26 </StackLayout> 27 </ContentPage>