Slider Constructors
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
Slider() |
Initializes a new instance of the Slider class. |
Slider(Double, Double, Double) |
Initializes a new instance of the Slider class. |
Slider()
Initializes a new instance of the Slider class.
public Slider ();
Remarks
The following example shows a basic use.
using System;
using Xamarin.Forms;
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)
Initializes a new instance of the Slider class.
public Slider (double min, double max, double val);
new Xamarin.Forms.Slider : double * double * double -> Xamarin.Forms.Slider
Parameters
- min
- System.Double
The minimum selectable value.
- max
- System.Double
The maximum selectable value.
- val
- System.Double
The actual value.