Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
Silverlight 3
Slider Class

  Switch on low bandwidth view
This page is specific to
Microsoft Silverlight 3

Other versions are also available for the following:
.NET Framework Class Library for Silverlight
Slider Class

Represents a control that lets the user select from a range of values by moving a Thumb control along a track.

Namespace:  System.Windows.Controls
Assembly:  System.Windows (in System.Windows.dll)
Visual Basic (Declaration)
<TemplatePartAttribute(Name := "VerticalTemplate", Type := GetType(FrameworkElement))> _
<TemplatePartAttribute(Name := "VerticalTrackLargeChangeDecreaseRepeatButton",  _
    Type := GetType(RepeatButton))> _
<TemplatePartAttribute(Name := "VerticalThumb", Type := GetType(Thumb))> _
<TemplatePartAttribute(Name := "VerticalTrackLargeChangeIncreaseRepeatButton",  _
    Type := GetType(RepeatButton))> _
<TemplatePartAttribute(Name := "HorizontalTemplate", Type := GetType(FrameworkElement))> _
<TemplatePartAttribute(Name := "HorizontalTrackLargeChangeIncreaseRepeatButton",  _
    Type := GetType(RepeatButton))> _
<TemplatePartAttribute(Name := "HorizontalTrackLargeChangeDecreaseRepeatButton",  _
    Type := GetType(RepeatButton))> _
<TemplatePartAttribute(Name := "HorizontalThumb", Type := GetType(Thumb))> _
<TemplateVisualStateAttribute(Name := "Disabled", GroupName := "CommonStates")> _
<TemplateVisualStateAttribute(Name := "Focused", GroupName := "FocusStates")> _
<TemplateVisualStateAttribute(Name := "MouseOver", GroupName := "CommonStates")> _
<TemplateVisualStateAttribute(Name := "Normal", GroupName := "CommonStates")> _
<TemplateVisualStateAttribute(Name := "Unfocused", GroupName := "FocusStates")> _
Public Class Slider _
    Inherits RangeBase
Visual Basic (Usage)
Dim instance As Slider
C#
[TemplatePartAttribute(Name = "VerticalTemplate", Type = typeof(FrameworkElement))]
[TemplatePartAttribute(Name = "VerticalTrackLargeChangeDecreaseRepeatButton", 
    Type = typeof(RepeatButton))]
[TemplatePartAttribute(Name = "VerticalThumb", Type = typeof(Thumb))]
[TemplatePartAttribute(Name = "VerticalTrackLargeChangeIncreaseRepeatButton", 
    Type = typeof(RepeatButton))]
[TemplatePartAttribute(Name = "HorizontalTemplate", Type = typeof(FrameworkElement))]
[TemplatePartAttribute(Name = "HorizontalTrackLargeChangeIncreaseRepeatButton", 
    Type = typeof(RepeatButton))]
[TemplatePartAttribute(Name = "HorizontalTrackLargeChangeDecreaseRepeatButton", 
    Type = typeof(RepeatButton))]
[TemplatePartAttribute(Name = "HorizontalThumb", Type = typeof(Thumb))]
[TemplateVisualStateAttribute(Name = "Disabled", GroupName = "CommonStates")]
[TemplateVisualStateAttribute(Name = "Focused", GroupName = "FocusStates")]
[TemplateVisualStateAttribute(Name = "MouseOver", GroupName = "CommonStates")]
[TemplateVisualStateAttribute(Name = "Normal", GroupName = "CommonStates")]
[TemplateVisualStateAttribute(Name = "Unfocused", GroupName = "FocusStates")]
public class Slider : RangeBase
XAML Object Element Usage
<Slider .../>

A Slider control lets users select a value from a range of values.

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 with the Orientation property.

  • The direction of increasing value along the Slider with the IsDirectionReversed property.

For more information about how to customize a Slider control, see the individual member.

NoteNote:

Due to the precedence of how dependency properties are set, if the Value property of the Slider is animated, the user may no longer be able set it when the animation finishes. For more information, see Dependency Property Value Precedence.

For a list of the initial property values for an instance of the Slider class, see the Slider()()() constructor.

Customizing the Slider Control

To apply the same property settings to multiple Slider controls, use the Style property. To change the visual structure and visual behavior of a Slider, copy and modify its default style and template. For more information, see Control Customization.

If a dependency property for a Slider is set by its default style, the property might change from its default value when the Slider appears in the application. For more information, see Dependency Property Value Precedence. You can get the default style and template for Slider from Slider Styles and Templates.

NoteNote:

Setting a visual property will only have an effect if that property is both present in Slider control's default template and is set by using a TemplateBinding. You can find a list of visual properties in the "Changing the Visual Structure of a Control" section of Customizing the Appearance of an Existing Control by Using a ControlTemplate.

The following code example shows how to use a slider control in XAML.

Run this sample

<Slider Margin="0,5,0,20"
    x:Name="slider1" 
    Minimum="0" 
    Maximum="10" />

<Slider Margin="0,5,0,20"
    x:Name="slider1" 
    Minimum="0" 
    Maximum="10" />

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker