#1,018 – Slider Basics
February 27, 2014 1 Comment
The Slider is a control that allows a user to drag a “thumb” across a range of values, to select a specific numeric value.
The Slider’s main properties are:
- Value – The numeric value selected by the slider
- Minimum – The minimum value that the slider can be set to (thumb dragged all of the way to the left)
- Maximum – The maximum value that the slider can be set to (thumb dragged all of the way to the right)
You’ll typically set the Minimum and Maximum to some static values, setting them in XAML to indicate the allowed range of values that a user is allowed to input.
You’ll typically bind the Value property to some property in code, allowing the user to set that value using the Slider.
<Slider Name="mySlider" Margin="10" Minimum="1" Maximum="100"/> <StackPanel Orientation="Horizontal"> <Label Content="Value:" VerticalAlignment="Center"/> <TextBlock Text="{Binding Path=Value, ElementName=mySlider}" Margin="10"/> </StackPanel>