Slider Class
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace: http://schemas.microsoft.com/winfx/2006/xaml/presentation
[LocalizabilityAttribute(LocalizationCategory::Ignore)] [TemplatePartAttribute(Name=L"PART_Track", Type=typeof(Track))] [TemplatePartAttribute(Name=L"PART_SelectionRange", Type=typeof(FrameworkElement))] public ref class Slider : public RangeBase
/** @attribute LocalizabilityAttribute(LocalizationCategory.Ignore) */ /** @attribute TemplatePartAttribute(Name="PART_Track", Type=System.Windows.Controls.Primitives.Track) */ /** @attribute TemplatePartAttribute(Name="PART_SelectionRange", Type=System.Windows.FrameworkElement) */ public class Slider extends RangeBase
LocalizabilityAttribute(LocalizationCategory.Ignore) TemplatePartAttribute(Name="PART_Track", Type=System.Windows.Controls.Primitives.Track) TemplatePartAttribute(Name="PART_SelectionRange", Type=System.Windows.FrameworkElement) public class Slider extends RangeBase
<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 descriptions and the Slider Overview.
The default value of the Maximum property is overridden by the Slider control class, as shown in the following table.
| Property | BaseClass | Default | SubClass | Default |
|---|---|---|---|---|
| Maximum | RangeBase | 1 | Slider | 10 |
This example shows how to create a horizontal Slider control
The following example shows how to create a horizontal Slider. In the code examples, the Slider is created as the child element of a Canvas (cv1).
<Slider Width="100" Value="0" Orientation="Horizontal" HorizontalAlignment="Left"/> <Slider Width="100" Height="30" Value="0" Orientation="Vertical"/>
For the complete sample, see Slider Sample.
More Code
| How to: Create a Slider with a TickBar | This example shows how to create a Slider control that has tick marks. |
| How to: Bind a Property to a Slider Value | This example shows how to bind the Height property of a Rectangle to the Value of a Slider control. |
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.