dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.04k stars 1.73k forks source link

Add Padding to CollectionView #21402

Open Alex-Dobrynin opened 6 months ago

Alex-Dobrynin commented 6 months ago

Description

Generally everything in the subject. I tried to override the default implementation of CollectionView handler. On Android this is not an issue, but with iOS cannot set UICollectionVIew.ContentInset = Padding, because ContentInset being reset by the internal implementation of CollectionView handler. So this is more architectural change of the handler and related things.

Public API Changes

var collView = new CollectionView();
collView.Padding = new Thickness(15);

Intended Use-Case

Padding for CollectionView can be very helpful, especially if you have GridLayout and you need space around edge views but the scrollbar stick to the edge. Doing it with margins of each item is not the proper way to achieve this, even more, in this case you need to calculate margins only for those edge views.

hansmbakker commented 6 months ago

Related to https://github.com/dotnet/maui/issues/11782 - unfortunately this has been requested since 2019

rmarinho commented 6 months ago

Duplicate of #11782

ewerspej commented 6 months ago

This would be very useful, I am facing this at the moment, as well.

dtavlikos commented 3 months ago

This needs to be implemented ASAP.

rbev commented 2 months ago

you can emulate this with ScrollView + StackLayout using BindableLayout attached properties - but it does not perform anywhere near as well.

it's annoying becuase I have some large buttons that overlay my content area, which means that without the ability to "scroll past" the end by ~30dp there is some information on the last item that gets covered up.

The other solution is to wrap all my data items in some container that gets told about it's index in the collection to add the final padding in - which is pretty ugly.

bradencohen commented 2 months ago

Would be super useful. Sharpnado Collection View has this implemented (a CollectionPadding property), if you can live with fixed item sizes.