Search code examples
xamarinxamarin.formsclickscrollviewtouch

Xamarin Forms ScrollView scrolls automatically to the beginning when any child element is clicked


I created a Horizontal / Vertical Scrollview in Xamarin Forms that contains several types of childs like:

  • Labels
  • CustomCheckboxes
  • ImageViews
  • Pickers
  • Sliders

enter image description here

Here is my code:

ScrollView scrollTracks = new ScrollView
{
     BackgroundColor = Color.Black,
     VerticalOptions = LayoutOptions.StartAndExpand,
     HorizontalOptions = LayoutOptions.FillAndExpand,
     Content = layoutTracks,
     Orientation = ScrollOrientation.Both
};

When I click some child elements like the CustomCheckboxes, or the Labels, or the ImageViews, the program scroll automatically the view to the beginning.

I tested this on the UWP platform.

How can I make the program to stop doing this?


Solution

  • Add this tag to the ScrollView solved my issue:

    IsTabStop = false
    

    Here the code:

    ScrollView scrollTracks = new ScrollView
    {
         BackgroundColor = Color.Black,
         VerticalOptions = LayoutOptions.StartAndExpand,
         HorizontalOptions = LayoutOptions.FillAndExpand,
         Content = layoutTracks,
         Orientation = ScrollOrientation.Both,
         IsTabStop = false
    };