在设计中,ListView需要嵌套到StackLayout中,但是ListView会出现一片空白部分,如何移除空白部分?

问题如图所示:

Xamarin.Forms 解决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>
View Code

相关文章:

  • 2021-08-24
  • 2021-12-12
  • 2021-11-07
  • 2022-12-23
  • 2021-06-22
  • 2021-11-05
  • 2021-11-30
猜你喜欢
  • 2022-01-09
  • 2022-12-23
  • 2022-12-23
  • 2021-11-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案