Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

How to hide scroll bar in scrollview

$
0
0
[assembly: ExportRenderer(typeof(ScrollView), typeof(App3.Droid.Scrollbardisabledrenderer))]

namespace App3.Droid
{
    public class Scrollbardisabledrenderer : ScrollViewRenderer
    {
        protected override void OnElementChanged(VisualElementChangedEventArgs e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null || this.Element == null)
                return;

            if (e.OldElement != null)
                e.OldElement.PropertyChanged -= OnElementPropertyChanged;

            e.NewElement.PropertyChanged += OnElementPropertyChanged;



        }

        protected void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (ChildCount > 0)
            {
                GetChildAt(0).HorizontalScrollBarEnabled = false;
                GetChildAt(0).VerticalScrollBarEnabled = false;
            }


                }
            }
        }

This is what i have done so far used this renderer in .droid , but when i run it in a simulator using a scroll view with simple boxes as children of a grid the scroll bar is visible , i am getting no errors while build . Is there something im missing in the procedure of custom renderers ? im new to coding all together have a basic understanding of c# and xaml please help me out with this advance topic


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>