locked
ListView VerticalScrollBarVisibility = "Always" not working. RRS feed

  • Question

  • User388416 posted

    I am using ListView to create a checkbox list and I want the scrollbar always visible so that the user can see there are more element below. Following is my XAML code:

    However, the scrollbar is only visible when I start scrolling and disappear again if I didn't touch on the screen which is just like the default setting. I have upgrade the Xamarin.Forms to the latest version 4.2.0.848062, is there any other way to make the scrollbar always visible? Thanks in advance.

    Tuesday, October 15, 2019 9:02 AM

Answers

  • User382871 posted

    is there any other way to make the scrollbar always visible? To achieve this, you need to create a ListView Custom Renderer. And set ScrollbarFadingEnabled property to false. page.xaml <local:CustomListView x:Name="listview"> <ListView.ItemTemplate> <DataTemplate> <ViewCell> <StackLayout> <Label Text="{Binding Content}"/> </StackLayout> </ViewCell> </DataTemplate> </ListView.ItemTemplate> </local:CustomListView> CustomListView.cs ``` public class CustomListView : ListView {

    } CustomListViewRenderer.cs [assembly: ExportRenderer(typeof(CustomListView), typeof(CustomListViewRenderer))] namespace App19F_2.Droid { public class CustomListViewRenderer : ListViewRenderer { public CustomListViewRenderer(Context context) : base(context) {

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

    } ```

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Tuesday, October 15, 2019 12:06 PM

All replies

  • User2148 posted

    If you think it's a bug I suggest to open an issue on https://github.com/xamarin/Xamarin.Forms

    Tuesday, October 15, 2019 9:04 AM
  • User382871 posted

    is there any other way to make the scrollbar always visible? To achieve this, you need to create a ListView Custom Renderer. And set ScrollbarFadingEnabled property to false. page.xaml <local:CustomListView x:Name="listview"> <ListView.ItemTemplate> <DataTemplate> <ViewCell> <StackLayout> <Label Text="{Binding Content}"/> </StackLayout> </ViewCell> </DataTemplate> </ListView.ItemTemplate> </local:CustomListView> CustomListView.cs ``` public class CustomListView : ListView {

    } CustomListViewRenderer.cs [assembly: ExportRenderer(typeof(CustomListView), typeof(CustomListViewRenderer))] namespace App19F_2.Droid { public class CustomListViewRenderer : ListViewRenderer { public CustomListViewRenderer(Context context) : base(context) {

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

    } ```

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Tuesday, October 15, 2019 12:06 PM
  • User388416 posted

    OMG, it works! Thank you Jarvan! You have no idea how much time I have spent on this.

    Wednesday, October 16, 2019 1:25 AM