CollectionView currently lacks a way to apply spacing around the collection of items whilst staying within the scrollable layout. This need is different from the spacing between individual items which has just been implemented.
public Thickness Padding { get; set; }
The property should work exactly as it does for everything inheriting from Layout.
The same reason you might use padding in a ScrollView instead of a margin. The first and last items should be inset from the edges, but as you scroll the content goes all the way to the edge.
4681 was already written out and #6478 was just recently merged.
Those issues look closed. How could one use the new ItemSpacing property to apply an inner spacing of 4 and an outer spacing of 16 for example? Another developer has mentioned the problem, but I don't see any action that would resolve the problem. https://github.com/xamarin/Xamarin.Forms/issues/4681#issuecomment-450746208
Padding property for CollectionView is very needed. When I want the same space between each item and at the same time screen edge, I have no chance to do it. For example (see the picture below) if I set HorizontalItemSpacing and VerticalItemSpacing to 5, I have 10 space between items, but only 5 from left, top and right edge. I can set Margin to 5 for whole CollectionView, but then scrollbar is not on the right and when I scroll down, 5 space remains on the top. And when I set these spacing to 0 and add margin to the layout of the item to "0,10,10,0" the dividing lines between elements after hovering the mouse (on UWP) are not in the middle between them.
Padding would solve it. I would set both spacings to 5 and padding to 5 and everything will be fine.
Yep. Still needed for grid layouts. For basic lists, blank headers and footers can be used to fake the missing padding property.
This has been closed but I'm struggling to see how to resolve this?
I need left and right margin around my items and as the margin is currently ignored (see #4692 which has also been closed with no visible fix) I have to add a ContentView to my DataTemplate so I can get a margin, which is adding unnecessary items to my visual tree which I'm trying to avoid.
@pauldipietro Can this be re-opened? The Padding
property is still missing
I need padding for CollectionView too. Because I need toolbar on the top of collectionView which disappear after scroll. So I need move the first item down.
+1 For re-opening this, I need spacing around my entire collection of items
@BeranekCZ and @kazo0 - I think content insets might be what you're looking for.
@pauldipietro I followed your comment and the ticket you referred to is about spacing between items and not padding. this is a fundamental principle of UI layout and I'm not sure why this is closed. all layout containers should have padding
Most helpful comment
@pauldipietro Can this be re-opened? The
Padding
property is still missing