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()
- 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
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈