Compartir a través de


Slider Constructors

Definition

Overloads

Slider()

Initializes a new instance of the Slider class.

Slider(Double, Double, Double)

Initializes a new instance of the Slider class.

Slider()

Source:
Slider.cs
Source:
Slider.cs

Initializes a new instance of the Slider class.

public:
 Slider();
public Slider ();
Public Sub New ()

Remarks

The following example shows a basic use.

using System;
using Microsoft.Maui.Controls;

namespace FormsGallery
{
    class SliderDemoPage : ContentPage
    {
        Label label;

        public SliderDemoPage()
        {
            Label header = new Label
            {
                Text = "Slider",
                Font = Font.BoldSystemFontOfSize(50),
                HorizontalOptions = LayoutOptions.Center
            };

            Slider slider = new Slider
            {
                Minimum = 0,
                Maximum = 100,
                VerticalOptions = LayoutOptions.CenterAndExpand
            };
            slider.ValueChanged += OnSliderValueChanged;

            label = new Label
            {
                Text = "Slider 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,
                    slider,
                    label
                }
            };
        }

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

Applies to

Slider(Double, Double, Double)

Source:
Slider.cs
Source:
Slider.cs

Initializes a new instance of the Slider class.

public:
 Slider(double min, double max, double val);
public Slider (double min, double max, double val);
new Microsoft.Maui.Controls.Slider : double * double * double -> Microsoft.Maui.Controls.Slider
Public Sub New (min As Double, max As Double, val As Double)

Parameters

min
Double

The minimum selectable value.

max
Double

The maximum selectable value.

val
Double

The actual value.

Applies to