Slider Class
This page is specific to:Microsoft Version:3.03.5Silverlight 34.0
.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)
Syntax

'Usage

Dim instance As Slider

'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
<Slider .../>
Remarks

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.

Examples

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" />
Inheritance Hierarchy

System..::.Object
  System.Windows..::.DependencyObject
    System.Windows..::.UIElement
      System.Windows..::.FrameworkElement
        System.Windows.Controls..::.Control
          System.Windows.Controls.Primitives..::.RangeBase
            System.Windows.Controls..::.Slider
Thread Safety

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

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

See Also

Reference

Other Resources

© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View