xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.62k stars 1.87k forks source link

[Enhancement] CollectionView To Scroll To The End Of Last Item #10978

Open MhAllan opened 4 years ago

MhAllan commented 4 years ago

Summary

If you have CollectionView and one of it's items height is larger than the CollectionView height and you try to scroll to that item, the collection view will scroll to the beginning of the item leaving the rest of that item hidden.

We should have way to allow the developer to chose which part of the item to show? start, end, or center? (this is different from where to put the item in the list)

We should have way to make CollectionView scrolls to the end of the item. This is important for anyone wants to make chat-like page. usually the list of messages scroll to the last message, when the user focuses on the Editor, the keyboard starts making the CollectionView shorter but still knows how to scroll to the end of the last message, not the beginning of last message.

Update

Workaround

If you use CollectionView.ScrollTo( ) with `ScrollToPosition.End and with animation set to true

CollectionView.ScrollTo(Item.Count - 1, -1, ScrollToPosition.End, true)

That will make the CollectionView scrolls to the end of last item. But if you set animation to false It will not

Attached Solution (Scroll to end of last item using ScrollTo)

CollectionViewTest.zip

animated vs not animated scroll screenshot

colview-scroll-end

stefanbogaard86 commented 4 years ago

Havn't tried it yet, but maybe snap points can accomplish this?

https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/collectionview/scrolling#snap-points

MhAllan commented 4 years ago

@stefanbogaard86 SnapPoints have no effect, plus Snapping is not an option at all for me

MhAllan commented 4 years ago

I found it is working fine using ScrollToPosition.End parameter in CollectionView.ScrollTo( ) The problem is that I was applying padding after the item is added so the CollectionView wasn't aware of the new size.

MhAllan commented 4 years ago

Reopen .. It is not working in all cases. Issue updated

viveklpu2011 commented 3 years ago

I have a footer in my collection view and i want to jump to footer , how will i jump, please any one can help?