Xamarin.Forms Guides | Samples

Xamarin.Forms.Stepper Class

A View control that inputs a discrete value, constrained to a range.

See Also: Stepper

Syntax

[Xamarin.Forms.RenderWith(typeof(Xamarin.Forms.Platform._StepperRenderer))]
public class Stepper : View, IElementConfiguration<Stepper>

Remarks

The following example shows a basic use.

C# Example

using System;
            using System;
            using Xamarin.Forms;

            namespace FormsGallery
            {
                class StepperDemoPage : ContentPage
                {
                    Label label;

                    public StepperDemoPage()
                    {
                        Label header = new Label
                        {
                            Text = "Stepper",
                            FontSize = Device.GetNamedSize (NamedSize.Large, typeof(Label)),
                            HorizontalOptions = LayoutOptions.Center
                        };

                        Stepper stepper = new Stepper
                        {
                            Value = 5,
                            Minimum = 0,
                            Maximum = 10,
                            Increment = 0.1,
                            HorizontalOptions = LayoutOptions.Center,
                            VerticalOptions = LayoutOptions.CenterAndExpand
                        };
                        stepper.ValueChanged += OnStepperValueChanged;

                        label = new Label
                        {
                            Text = String.Format("Stepper value is {0:F1}", stepper.Value),
                            FontSize = Device.GetNamedSize (NamedSize.Large, typeof(Label)),
                            HorizontalOptions = LayoutOptions.Center,
                            VerticalOptions = LayoutOptions.CenterAndExpand
                        };

                        // Accomodate iPhone status bar.
                        this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);

                        // Build the page.
                        this.Content = new StackLayout
                        {
                            Children =
                            {
                                header,
                                stepper,
                                label
                            }
                            };
                    }

                    void OnStepperValueChanged(object sender, ValueChangedEventArgs e)
                    {
                        label.Text = String.Format("Stepper value is {0:F1}", e.NewValue);
                    }
                }
            }

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

PropertyValue
Increment

An integer or decimal literal.

Maximum

An integer or decimal literal.

Minimum

An integer or decimal literal. If this value is nonnegative, it must appear lexically below Maximum, so that validation can succeed.

Value

An integer or decimal literal that represents a number that is in the range [Minimum,Maximum].

ValueChangedThe name of an event handler. Note that this tag must appear below Value.

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.3.0.0, 1.4.0.0, 1.5.0.0, 2.0.0.0

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

See Also: View

Public Constructors

Initializes a new instance of the Stepper class.
Initializes a new instance of the Stepper class.

Public Fields

static readonly
IncrementPropertyBindableProperty. Identifies the Increment bindable property.
static readonly
MaximumPropertyBindableProperty. Identifies the Maximum bindable property.
static readonly
MinimumPropertyBindableProperty. Identifies the Minimum bindable property.
static readonly
ValuePropertyBindableProperty. Identifies the Value bindable property.

Public Properties

IncrementDouble. Gets or sets the increment by which Value is increased or decreased. This is a bindable property.
MaximumDouble. Gets or sets the maximum selectable value. This is a bindable property.
MinimumDouble. Gets or sets the minimum selectabel value. This is a bindable property.
ValueDouble. Gets or sets the current value. This is a bindable property.

Public Methods

On<T>() : IPlatformElementConfiguration<T, Stepper>
Returns the platform-specific instance of this Stepper, on which a platform-specific method may be called.

Public Events

ValueChangedRaised when the Stepper.Value property changes.