为了账号安全,请及时绑定邮箱和手机立即绑定

XAML 中的 Xamarin.Forms ListView 自动高度

XAML 中的 Xamarin.Forms ListView 自动高度

C#
慕丝7291255 2022-12-24 09:57:26
我有带 ViewCell 的 ListView,它的 ViewCell 包含带有大文本的标签。如何制作自动高度的 ViewCell???我的 XAML 代码:    <ContentPage  xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Physis.Movements_And_Interactions_Page" xmlns:local="clr-namespace:Physis">    <ContentPage.ToolbarItems>     <ToolbarItem  x:Name="settings" Text="{Binding settings_text}" Clicked="Handle_Clicked"/>    </ContentPage.ToolbarItems>    <ContentPage.Content>     <StackLayout Margin="20,35,20,20" x:Name="Main_View2" >            <ListView x:Name="Main_Menu" ItemsSource="{Binding Planets}" ItemSelected="Handle_ItemSelected" ItemTapped="Handle_ItemTapped" BackgroundColor="{DynamicResource Key=backgroundColor}" SeparatorColor="{DynamicResource Key=textColor}">            <ListView.ItemTemplate>            <DataTemplate >             <ViewCell >              <StackLayout Orientation="Vertical" >               <Label Text="{Binding Name}" StyleClass="Body"/>               <Label Text="{Binding Description}" StyleClass="Body"/>                            </StackLayout>             </ViewCell>            </DataTemplate>             </ListView.ItemTemplate>              </ListView>      </StackLayout ></ContentPage.Content>感谢大家!
查看完整描述

1 回答

?
尚方宝剑之说

TA贡献1788条经验 获得超4个赞

HasUnevenRows="true"在您的 ListView 上设置。请参阅此处的文档https://learn.microsoft.com/en-us/dotnet/api/Xamarin.Forms.ListView.HasUnevenRows?view=xamarin-forms


查看完整回答
反对 回复 2022-12-24
  • 1 回答
  • 0 关注
  • 83 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信