Using a Scrollview in XamarinForms

What is it ???

The short answer is ScrollView is a Layout. But it can only contain a single Visual Element in its Content property.

Why So ???

Because, the Layouts such as Stack, relative etc. are derived from Layout<T> generic class. This Layout<T> generic class is derived from the Layout class, which is a non-generic class.

ScrollView is inherited from the Non-generic Layout class. That is the same reason, why it does not support a generic way to add children. It only exhibits the Content property to accept a single view or a Layout.


Usage by example

Usage Example #1 : Let’s display a paragraph of scrolling text

Lesson learnt : The ScrollView can be placed directly on the page itself with a single view in it. After we run this, it keeps the screen scrollable in order to read the content.

Usage Example #2 : Let’s create a standard terms and condition page

 Lesson learnt : From this usage example, the ScrollView can be placed inside another Layout (i.e. Stackayout in this case).

Usage Example #3 : Let’s display Customer details input screen

 Lesson learnt : Not only a single view but also another Layout (StackLaout in this case) can be placed inside a ScrollView too.

Note : I am using Visual Studio with Xamarin.Forms 1.3

That’s it. Happy coding  🙂

Categories: Android, Cross Platform Mobile App, CSharp, iOS, Visual Studio, Windows Phone, Xamarin

Leave a Reply

%d bloggers like this: