[英]Xamarin - CollectionView extra space for first and last item
Hello guys,大家好,
my question is if I'am able to add some extra space above first item and under last item in CollectionView in Xamarin.我的问题是我是否能够在 Xamarin 的 CollectionView 中的第一项上方和最后一项下方添加一些额外的空间。
I have items styled like card with rounded corners but at the moment it can't be seen clearly because there is no space above first and under last item.我有类似圆角卡片的物品,但目前看不清楚,因为第一个物品上方和最后一个物品下方没有空间。 Vertical space between them is okay with ItemSpacing property.
它们之间的垂直空间可以使用 ItemSpacing 属性。
I will add screenshot here.
我将在此处添加屏幕截图。 The blackline is the exact place where I need space.
黑线是我需要空间的确切位置。
As jason said that you can add padding or Margin for Grid or stacklayout, then add CollectionView in this layout.正如 jason 所说,您可以为 Grid 或 stacklayout 添加 padding 或 Margin,然后在此布局中添加 CollectionView。
<Grid Padding="20">
<CollectionView ItemsSource="{Binding images}">
<CollectionView.ItemTemplate>
<DataTemplate>
<Frame BorderColor="Black" CornerRadius="30">
<StackLayout>
<Image Source="{Binding imagepath}" />
<Label Text="{Binding text}" />
</StackLayout>
</Frame>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</Grid>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.