xamarin.forms - Xamarin.Forms:列表变得比列表视图中的项目长
问题描述
这是我在滚动视图中的网格:
<ScrollView>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Button Text="asd1" x:Name="row1" Grid.Row="0"/>
<Grid x:Name="row2"
Grid.Row="1"
IsVisible="false"
Margin="30,0,0,0"
BackgroundColor="Yellow">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<ListView x:Name="list_cat1"
Grid.Row="0">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Label Text="{Binding subCatName}" >
<Label.GestureRecognizers>
<TapGestureRecognizer Tapped="GetClick"/>
</Label.GestureRecognizers>
</Label>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
<Button Text="asd3" x:Name="row3" Grid.Row="2"/>
</Grid>
</ScrollView>
但这是我喂它数据_
private void SetCategories()
{
List<CategoryType> allCatsInsideSubs = FilteringSingleton.Instance.GetCategories();
List<SubCategoryType> sub1 = new List<SubCategoryType>();
for(int i = 0; i < allCatsInsideSubs.Count; i++)
{
if (allCatsInsideSubs[i].categoryOrder == (int)CategoryOdersEnum.Deko)
{
SubCategoryType x = new SubCategoryType();
x.subCatName = allCatsInsideSubs[i].subCategory;
x.subCatID = allCatsInsideSubs[i].subCategoryOrder;
sub1.Add(x);
}
}
list_cat1.ItemsSource = sub1;
}
但结果是这样的:
如您所见,列表比其中的项目长得多。您实际上可以向下滚动一会儿,直到黄色停止并且下一个按钮变得可见。每一行都设置为自动。这个额外的空间是从哪里来的?
我也注意到,当我将更多数据放入列表视图时,它不再太长
解决方案
推荐阅读
- flutter - SplashScreen 未将用户导航到其他页面
- flutter - 为什么ontap会更改所有卡
- javascript - 连接的 mongodb atlas 仍然我的网络应用程序没有运行
- pyqt5 - 无法使用 QThread 同时运行两个事件
- html - 如何将文本作为伪元素添加到元素
- javascript - 使用 google/facebook 护照策略登录同一个帐户
- yaml - 尽管有 .codeclimate.yaml 文件,但不能忽略行长
- c++ - 我应该使用 ExitThread() 还是从 C++ 中的线程返回
- html - 在 VS 2019 中寻找类似于“HTML(Web 表单)编辑器”的 VSCode 扩展
- velocity - 我的 atlassian-plugin.xml 中 $generalUtil 的来源是什么?