Export (0) Print
Expand All

TickBar Class

Represents a control that draws a set of tick marks for a Slider control.

Namespace: System.Windows.Controls.Primitives
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

[LocalizabilityAttribute(LocalizationCategory.None, Readability=Readability.Unreadable)] 
public class TickBar : FrameworkElement
/** @attribute LocalizabilityAttribute(LocalizationCategory.None, Readability=Readability.Unreadable) */ 
public class TickBar extends FrameworkElement
LocalizabilityAttribute(LocalizationCategory.None, Readability=Readability.Unreadable) 
public class TickBar extends FrameworkElement

The TickBar control draws tick marks that have a width of one pixel. You can define the location of the tick marks by specifying a repeating interval or a series of explicit points.

The TickBar control is specifically designed to work with a Slider control. A Slider displays tick marks. The following illustration shows a Slider that has a TickBar.

Slider with a TickBar

Slider illustration

TickBar controls are typically defined in the Style of a Slider. For an example of a TickBar that is included in a Slider Style, see Slider Control Template.

The TickBar and Slider controls both contain properties that perform the same function. The following table shows the TickBar properties and the corresponding Slider properties to which they are bound. The TickBar properties take precedence when Slider and TickBar properties that are related are both specified.

Related TickBar and Slider Properties

This example shows how to create a Slider control that has tick marks.

When you create a Slider, the default style provides a TickBar 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.

<Slider Name="slider1" Width="100" 
        Orientation="Horizontal" HorizontalAlignment="Left" 
        IsSnapToTickEnabled="True" Minimum="1" Maximum="9" 
        TickPlacement="BottomRight"  TickFrequency="3"
        AutoToolTipPrecision="2" AutoToolTipPlacement="BottomRight"

The following example shows how to use the Ticks property to create a tick mark collection. The example uses the collection to place tick marks at non-uniform positions along the Slider.

 <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 Sample.


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

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.

.NET Framework

Supported in: 3.0

Community Additions

© 2015 Microsoft