Stepperコントロールは、任意の範囲から値を選択するコントロールです。

ここでは以下について説明します。


現在値を設定する

現在値を設定するには、Value プロパティを使用します。既定値は0です。

以下は、XamlでStepperのValueプロパティに50を設定する例です。

MainPage.xaml
  <Stepper x:Name="stepper1" Value="50" />

コードでStepperコントロールに現在値を設定するには、以下のようにします。

MainPage.xaml.cs
  namespace stepperSample01
{
    public partial class MainPage : ContentPage
    {
        public MainPage()
        {
            InitializeComponent();

            // Stepperの現在値を50に設定
            stepper1.Value = 50;
        }
    }
}


現在値を取得する

現在値を取得する場合も、Value プロパティを使用します。

以下は、StepperのValueプロパティを取得してLabelに表示するXamlの例です。

MainPage.xaml
  <Stepper x:Name="stepper1" Value="50" />
        
<!-- Stepperの現在値を表示 -->
<Label Text="{Binding Source={x:Reference stepper1}, Path=Value, StringFormat='{0:F0}'}"
        HorizontalOptions="Center"
        VerticalOptions="CenterAndExpand" />

コードでStepperコントロールの現在値を取得してLabelに表示する例を以下に示します。

MainPage.xaml.cs
  namespace stepperSample01
{
    public partial class MainPage : ContentPage
    {
        public MainPage()
        {
            InitializeComponent();

            // Stepperの現在値を50に設定
            stepper1.Value = 50;
        }
    }
}

実行例を以下に示します。