Disable bounce in iOS ListView for Xamarin.Forms

Environment

Product Version 2020.2.624.1
Product ListView for Xamarin Cross-Platform

Description

The purpose of this article is to show you how to disable the listview bounce on iOS. In addition you can also disable the scrolling.

Solution

The scenario could be achieved using custom renderer for iOS. Create a class inside the iOS project, for example CustomListViewRenderer which inherits from ListViewRenderer. Then override the OnElementchangedMethod and inside it disable the bounces.

Here is the custom renderer implementation:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Foundation;
using ListView.iOS;
using Telerik.XamarinForms.DataControlsRenderer.iOS;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;

[assembly: ExportRenderer(typeof(Telerik.XamarinForms.DataControls.RadListView), typeof(CustomListViewRenderer))]

namespace ListView.iOS
{
    public class CustomListViewRenderer : Telerik.XamarinForms.DataControlsRenderer.iOS.ListViewRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<Telerik.XamarinForms.DataControls.RadListView> e)
        {
            base.OnElementChanged(e);

            var control = this.Control as TKExtendedListView;
            if(control != null)
            {
                control.Layout.CollectionView.Bounces = false;

                // in additiona you can disable the scrolling setting the scrollenabled to false. Check the commented code below:
                //control.Layout.CollectionView.ScrollEnabled = false;
            }
        }
    }
}
In this article
Not finding the help you need? Improve this article