How to hide the scrollbar in listview

Viewed 609

I am trying to hide the scrollbar in list view, I followed this, But I am getting the following error

ListView does not contain definition for VerticalScrollbarEnabled

Here is what I did:

[assembly: ExportRenderer(typeof(Xamarin.Forms.ListView), typeof(CustomListView))]

namespace MyApp.Droid.Renderer
{
    class CustomListView:ListViewRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.ListView> e)
        {
            base.OnElementChanged(e);
            Xamarin.Forms.ListView.VericalScrollbarEnabled = false;          

        }        
    }
}

How to give this property for ListView.

2 Answers

You need to set VerticalScrollBarEnabled on the native control, not the Forms' based one:

class CustomListView : ListViewRenderer
{
    protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.ListView> e)
    {
        base.OnElementChanged(e);
        if (Control != null)
            Control.VerticalScrollBarEnabled = false;
    }
}

Try this in your layout file

android:scrollbars="none"

This should probably work.

Related