Slider Class
Updated: February 2009
Assembly: PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
'Declaration <LocalizabilityAttribute(LocalizationCategory.Ignore)> _ <TemplatePartAttribute(Name := "PART_Track", Type := GetType(Track))> _ <TemplatePartAttribute(Name := "PART_SelectionRange", Type := GetType(FrameworkElement))> _ Public Class Slider _ Inherits RangeBase 'Usage Dim instance As Slider
<Slider .../>
A Slider control lets users select a value from a range of values. The following illustration shows an example of a Slider control.
Example of a Slider Control

You can customize a Slider control by setting its properties. The following list describes some of the attributes of a Slider that you can customize:
The orientation of the Slider, either horizontal or vertical.
The tick mark locations along the Slider track.
The display of tooltips to show the current value of the Slider.
The ability of the Thumb to either snap to tick marks or to be positioned at any point along the Slider.
The direction of increasing value along the Slider.
For more information about how to customize a Slider control, see the individual member.
Slider overrides the metadata of the Maximum property and sets its default to 10. For more information, see Dependency Properties Overview.
Note: |
|---|
If the value of the Slider is animated, the user may no longer be able to interact with the Slider control after the animation finishes. See How to: Set a Property After Animating It with a Storyboard for options of how you can restore user control of a Slider after it is animated. |
Dependency properties for this control might be set by the control’s default style. If a property is set by a default style, the property might change from its default value when the control appears in the application. The default style is determined by which desktop theme is used when the application is running. For more information, see Themes.
This example shows how to create a Slider control that has tick marks.
The TickBar displays when you set the TickPlacement property to a value other than None, which is the default value.
The following example shows how to create a Slider with a TickBar that displays tick marks. The TickPlacement and TickFrequency properties define the location of the tick marks and the interval between them. When you move the Thumb, tooltips display the value of the Slider. The AutoToolTipPlacement property defines where the tooltips occur. The Thumb movements correspond to the location of the tick marks because IsSnapToTickEnabled is set to true.
The following example shows how to use the Ticks property to create tick marks along the Slider at irregular intervals.
<Slider Width="100" Value="50" Orientation="Horizontal" HorizontalAlignment="Left" IsSnapToTickEnabled="True" Maximum="3" TickPlacement="BottomRight" AutoToolTipPlacement="BottomRight" AutoToolTipPrecision="2" Ticks="0, 1.1, 2.5, 3"/>
For the complete sample, see Slider with Data Binding Sample.
More Code
| How to: Bind a Slider to a Property Value | This example shows how to bind the Height property of a Rectangle to the Value of a Slider control. |
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Note: