2016-08-04 3 views
2

У меня есть ListView в Xamarin Forms XAML, в этом ListView я хочу нарисовать сетку с 4 метками и 1 Entry. Моя проблема в том, что когда я пытаюсь отобразить ListView, его строки накладываются, и не отображается весь контент ViewCell в DataTemplate.ViewCell не правильно выровнять и вырезать часть содержимого - Xamarin Forms

Я не знаю, что такое моя ошибка.

Вот мой код:

<?xml version="1.0" encoding="UTF-8"?> 
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="iGuideTest.ExhibitionsPage" 
    Title = "{Binding titleMenu}"> 
<ContentPage.Content> 
    <StackLayout VerticalOptions="Center" HorizontalOptions="Center"> 
      <Label Text="You are in the Exhibitions page" /> 
      <Button Text="Return to LoginPage" Command="{Binding BackCommand}" /> 
      <Label Text="{Binding exhibitionsList.Count}" /> 
     <Button Grid.Row="2" Grid.Column="0" Text="{Binding surname}" Command="{Binding Edit}" /> 
      <ListView x:Name="ListViewCouchbase" ItemsSource="{Binding exhibitionsList}" 
       > 
       <ListView.ItemTemplate> 
        <DataTemplate> 
        <ViewCell> 
           <Grid> 
            <Grid.RowDefinitions> 
             <RowDefinition Height="Auto" /> 
             <RowDefinition Height="Auto" /> 
             <RowDefinition Height="*" /> 
            </Grid.RowDefinitions> 
            <Grid.ColumnDefinitions> 
             <ColumnDefinition Width="Auto" /> 
             <ColumnDefinition Width="Auto" /> 
            </Grid.ColumnDefinitions> 
           <Label Grid.Row="0" Grid.Column="0" TextColor="#05199C" Text="{Binding title}" /> 
           <Label Grid.Row="0" Grid.Column="1" TextColor="#008000" Text="{Binding userId}" /> 
           <Label Grid.Row="1" Grid.Column="1" TextColor="Maroon" Text="{Binding LastUpdated}" /> 
           <Label Grid.Row="1" Grid.Column="0" TextColor="Purple" Text="{Binding surname}" /> 
           <Entry Grid.Row="2" Grid.Column="0" TextColor="Blue" Text="{Binding Id}" /> 
           </Grid> 
        </ViewCell> 
        </DataTemplate> 
       </ListView.ItemTemplate> 
      </ListView> 
    </StackLayout> 
</ContentPage.Content> 

Спасибо заранее.

+0

Вам не хватает 'RowHeight' для вашего списка. – Krumelur

+0

Я уже установил RowDefinition Height = "Auto" – rik194

ответ

5

Попробуйте использовать HasUnevenRows недвижимость:

<ListView HasUnevenRows="True"> ... </ListView>

0

Да, я был там :)

просто установить ListView RowHeight = "хх", где хх это некоторый двойной указывающий высоту.

0

Поскольку вы используете Grid, и у вас есть Auto в RowHeight, вам будет лучше установить свойство HasUnevenRows на true.

Также ваша сетка имеет динамический размер сама по себе, вы можете установить ее VerticalOptions на Fill.