简体   繁体   中英

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.

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.

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.

 <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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM