英文:
Label height in a CollectionView DataTemplate
问题
Objects 在 CollectionView 或 DataTemplate 中是否会自动填充或其他什么?我可以尝试更改 CollectionView 中标签的高度,但这只会影响标签部分,而不是我想要减小的额外填充。当我减小标签高度时,它只是遮挡了文本,所以我想知道是否有一种方法可以减小这个填充或边距,因为在 PC 上看起来不太好。
我有的基本 XAML 代码如下:
<CollectionView
x:Name="ResponseCollectionView"
ItemsSource="{Binding Responses}"
BackgroundColor="#404040"
HeightRequest="200"
>
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="{x:Type x:String}">
<Label Text="{Binding .}" BackgroundColor="#303030" />
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
英文:
Are the objects in the CollectionView or DataTemplate automatically padded or something? I can try to change the height of the label in a CollectionView but that only affects the label portion of it and not this extra padding which I would like to reduce. When I reduce label height, it just masks the text so I'm wondering if there is a way to reduce this padding or margin because it doesn't look great on PC.
The basic xaml code I have is this:
<CollectionView
x:Name="ResponseCollectionView"
ItemsSource="{Binding Responses}"
BackgroundColor="#404040"
HeightRequest="200"
>
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="{x:Type x:String}" >
<Label Text="{Binding .}" BackgroundColor="#303030" />
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
答案1
得分: 1
The padding issue is caused by the Windows implementation of CollectionView having an inaccessible Checkbox included in each line. The perceived padding is caused by the height of the line not reducing to smaller than the height of the checkbox. If you go in-depth into the live layout for the CollectionView you can see the checkbox and how it affects the height.
英文:
The padding issue is caused by the Windows implementation of CollectionView having an inaccessible Checkbox included in each line. The perceived padding is caused by the height of the line not reducing to smaller than the height of the checkbox. If you go in-depth into the live layout for the CollectionView you can see the checkbox and how it affects the height.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论