Hi,
I really need to use an event that notifies me when the user stops scrolling (lifting finger from the display). Since Xamarin.Forms's CollectionView does not currently has that event built-in (that I can see anyways) I decided to create a custom renderer that extends the stock CollectionView. I'm quite new to all of this so I'm not sure if this is the best way.
Long story short, this functionality now works but I have unfortunately removed all the other events from my custom CollectionView. The code below is how I achieved this and I believe it's the fact that I overnight the control's delegates that it's not working. How do I do this without overriding the rest of the functionality?
using System.Diagnostics; using Foundation; using test.Controls; using test.iOS; using UIKit; using Xamarin.Forms; using Xamarin.Forms.Platform.iOS; [assembly: ExportRenderer(typeof(MyCollectionView), typeof(MyCollectionViewRenderer))] namespace test.iOS { public class MyCollectionViewRenderer : CollectionViewRenderer, IUICollectionViewDelegate, IUIScrollViewDelegate { protected override void OnElementChanged(ElementChangedEventArgs<GroupableItemsView> e) { base.OnElementChanged(e); if (Control != null) { NSArray views = Control.ValueForKey(new NSString("_subviewCache")) as NSMutableArray; UICollectionView collectionView = views.GetItem<UICollectionView>(0); var oldDelegates = collectionView.WeakDelegate; collectionView.Delegate = new MyCollectionViewDelegate((MyCollectionView)Element); } } } public class MyCollectionViewDelegate : UICollectionViewDelegate { MyCollectionView customView; public MyCollectionViewDelegate(MyCollectionView collectionView) { this.customView = collectionView; } [Foundation.Export("scrollViewDidEndDragging:willDecelerate:")] public void ScrollEnded(UIKit.UIScrollView scrollView, bool willDecelerate) { Debug.WriteLine("Finished Scrolling"); customView.RaiseScrollEnded(customView, willDecelerate); } } }