See Also: Stepper Members
The following example shows a basic use.
C# Example
using System;
using Xamarin.Forms;
namespace FormsGallery
{
class StepperDemoPage : ContentPage
{
Label label;
public StepperDemoPage()
{
Label header = new Label
{
Text = "Stepper",
Font = Font.BoldSystemFontOfSize(50),
HorizontalOptions = LayoutOptions.Center
};
Stepper stepper = new Stepper
{
Minimum = 0,
Maximum = 10,
Increment = 0.1,
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.CenterAndExpand
};
stepper.ValueChanged += OnStepperValueChanged;
label = new Label
{
Text = "Stepper value is 0",
Font = Font.SystemFontOfSize(NamedSize.Large),
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);
}
}
}
The Xamarin.Forms.Stepper class has the following XAML properties:
| Property | Value |
|---|---|
| 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]. |
| ValueChanged | The name of an event handler. Note that this tag must appear below Value. |