Xamarin.Forms Guides | Samples

Xamarin.Forms.ScrollView Class

An element capable of scrolling if its Content requires.

See Also: ScrollView

Syntax

[Xamarin.Forms.ContentProperty("Content")]
[Xamarin.Forms.RenderWith(typeof(Xamarin.Forms.Platform._ScrollViewRenderer))]
public class ScrollView : Layout, IElementConfiguration<ScrollView>, IScrollViewController

Remarks

The following example shows the creation of a ScrollView with a large StackLayout in it.

C# Example

var stack = new StackLayout();

for (int i = 0; i < 100; i++)
{
    stack.Children.Add(new Button { Text = "Button " + i });
}

MainPage = new ContentPage
{
    Content = new ScrollView { Content = stack }
};
Note: Application developers should not nest one ScrollView within another. Additionally, they should refrain from nesting them other elements that can scroll, such as WebView.

XAML for Xamarin.Forms supports the following properties for the ScrollView class:

PropertyValue
Content

Markup that specifies a View to display in the ScrollView.

Orientation

Horizontal or Vertical, to indicate the scroll direction.

Requirements

Namespace: Xamarin.Forms
Assembly: Xamarin.Forms.Core (in Xamarin.Forms.Core.dll)
Assembly Versions: 1.0.0.0, 1.1.0.0, 1.2.0.0, 1.2.3.0, 1.3.0.0, 1.4.0.0, 1.5.0.0, 2.0.0.0

The members of Xamarin.Forms.ScrollView are listed below.

See Also: Layout

Public Constructors

Initializes a new instance of the ScrollView class.

Public Fields

static readonly
ContentSizePropertyBindableProperty. Identifies the ContentSize bindable property.
static readonly
OrientationPropertyBindableProperty. Identifies the Orientation bindable property.
static readonly
ScrollXPropertyBindableProperty. Backing store for the ScrollView.ScrollX property.
static readonly
ScrollYPropertyBindableProperty. Backing store for the ScrollView.ScrollY property.

Public Properties

ContentView. Gets or sets a View to display in the ScrollView.
[read-only]
ContentSizeSize. Gets the size of the Content. This is a bindable property.
OrientationScrollOrientation. Gets or sets the scrolling direction of the ScrollView. This is a bindable property.
[read-only]
ScrollXDouble. Gets the current X scroll position.
[read-only]
ScrollYDouble. Gets the current Y scroll position..

Public Methods

On<T>() : IPlatformElementConfiguration<T, ScrollView>
Returns the platform-specific instance of this ScrollView, on which a platform-specific method may be called.
ScrollToAsync(Double, Double, Boolean) : Task
Returns a task that scrolls the scroll view to a position asynchronously.
ScrollToAsync(Element, ScrollToPosition, Boolean) : Task
Returns a task that scrolls the scroll view to an element asynchronously.

Protected Methods

override
LayoutChildren(Double, Double, Double, Double)
Positions and sizes the content of a ScrollView.
override
OnSizeRequest(Double, Double) : SizeRequest
This method is called during the measure pass of a layout cycle to get the desired size of an element.

Public Events

ScrolledEvent that is raised after a scroll completes.

Explicitly Implemented Interface Members