【问题标题】:Xamarin.Forms ListView AutoHeight in XAMLXAML 中的 Xamarin.Forms ListView AutoHeight
【发布时间】:2019-04-21 16:07:35
【问题描述】:

我有带有 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>

谢谢大家!

【问题讨论】:

    标签: c# xaml listview xamarin.forms


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2014-08-17
      • 2023-03-29
      • 2018-05-28
      • 2016-01-21
      • 2018-04-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多