Xamarin.Forms ListView AutoHeight в XAML - PullRequest
1 голос
/ 21 апреля 2019

У меня есть ListView с ViewCell, и его ViewCell содержит Label с огромным текстом.Как мне сделать ViewCell с автоматической высотой ???

Снимок экрана проблемы Screenshot of issue

Мой код 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 Ответ

2 голосов
/ 21 апреля 2019

Установите HasUnevenRows="true" в вашем ListView. Смотри документацию здесь https://docs.microsoft.com/en-us/dotnet/api/Xamarin.Forms.ListView.HasUnevenRows?view=xamarin-forms

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...