Slider.Ticks Property
.NET Framework 4
Gets or sets the positions of the tick marks to display for a Slider.
Assembly: PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
<object> <object.Ticks> <DoubleCollection .../> </object.Ticks> </object>
<object Ticks="DoubleCollection" .../>
Property Value
Type: System.Windows.Media.DoubleCollectionA set of tick marks to display for a Slider. The default is null.
Tick marks that are outside the range that is defined by the Minimum and Maximum property values are ignored.
The TickPlacement property must be set to a value other than None for tick marks to appear.
The following example shows how to set the Ticks property.
Slider hslider = new Slider(); hslider.Orientation = Orientation.Horizontal; hslider.Width = 100; hslider.Minimum = 1; hslider.Maximum = 10; hslider.IsDirectionReversed = true; hslider.IsMoveToPointEnabled = true; hslider.AutoToolTipPrecision = 2; hslider.AutoToolTipPlacement = AutoToolTipPlacement.BottomRight; hslider.TickPlacement = TickPlacement.BottomRight; // Manually add ticks to the slider. DoubleCollection tickMarks = new DoubleCollection(); tickMarks.Add(0.5); tickMarks.Add(1.5); tickMarks.Add(2.5); tickMarks.Add(3.5); tickMarks.Add(4.5); tickMarks.Add(5.5); tickMarks.Add(6.5); tickMarks.Add(7.5); tickMarks.Add(8.5); tickMarks.Add(9.5); hslider.Ticks = tickMarks; // Create a selection range. hslider.IsSelectionRangeEnabled = true; hslider.SelectionStart = 2.5; hslider.SelectionEnd = 7.5; cv2.Children.Add(hslider);
<Slider Width="100" Orientation="Horizontal" Minimum="1" Maximum="10" IsDirectionReversed="True" IsMoveToPointEnabled="True" AutoToolTipPrecision="2" AutoToolTipPlacement="BottomRight" TickPlacement="BottomRight" Ticks="0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5" IsSelectionRangeEnabled="true" SelectionStart="2.5" SelectionEnd="7.5" Name="mySlider"/>
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.