Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xaml 具有多行的Xamarin数据模板_Xaml_Xamarin - Fatal编程技术网

Xaml 具有多行的Xamarin数据模板

Xaml 具有多行的Xamarin数据模板,xaml,xamarin,Xaml,Xamarin,我有一个listview和一个datatemplate <ListView x:Name="list" ItemsSource="{Binding MyList}" HorizontalOptions="Center" VerticalOptions="FillAndExpand"> <ListView.ItemTemplate>

我有一个listview和一个datatemplate

 <ListView x:Name="list"
                     ItemsSource="{Binding MyList}"
                     HorizontalOptions="Center" 
                     VerticalOptions="FillAndExpand">
        <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell> 
                      <Grid Padding="5"> 
                        <Grid.RowDefinitions> 

                          <RowDefinition Height="20"></RowDefinition> 
                          <RowDefinition Height="20"></RowDefinition> 
                          <RowDefinition Height="20"></RowDefinition> 
                          <RowDefinition Height="20"></RowDefinition> 
                          </Grid.RowDefinitions> 

                             <Grid.ColumnDefinitions> 
                            <ColumnDefinition Width="1*"></ColumnDefinition> 
                            <ColumnDefinition Width="1*"></ColumnDefinition> 
                            </Grid.ColumnDefinitions>   

                            <Label Grid.Row="0" Grid.Column="0" Text="First"></Label> 
                            <Label Grid.Row="0" Grid.Column="1" Text="{Binding First}"></Label>

                            <Label Grid.Row="1" Grid.Column="0" Text="Second"></Label> 
                            <Label Grid.Row="1" Grid.Column="1" Text="{Binding Second}"></Label>

                            <Label Grid.Row="2" Grid.Column="0" Text="Third"></Label> 
                            <Label Grid.Row="2" Grid.Column="1" Text="{Binding Third}"></Label>

                            <Label Grid.Row="3" Grid.Column="0" Text="Fourth"></Label> 
                            <Label Grid.Row="3" Grid.Column="1" Text="{Binding Forth}"></Label>

                      </Grid> 
                  </ViewCell> 
              </DataTemplate>
          </ListView.ItemTemplate>
      </ListView>

这里的问题是只显示前两行。对于仅允许显示两行的viewCell,是否存在一些限制


有没有更好的方法来实现我的目标?我可以使用datatemplate中的表吗?谢谢

尝试添加到
ListView
a
RowHeight
定义中

例如,我会尝试以下方法:

<ListView x:Name="list"
                 ItemsSource="{Binding MyList}"
                 HorizontalOptions="Center" 
                 VerticalOptions="FillAndExpand"
                 RowHeight="100">
  ...
  </ListView>

...

为什么设置HorizontalOptions=“Center”?如果您的页面仅包含此列表,请将其设置为HorizontalOptions=“FillAndExpand”谢谢,行高成功了!