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)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation

[LocalizabilityAttribute(LocalizationCategory.None, Readability = Readability.Unreadable)]
public class TickBar : 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 ControlTemplate Example.

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.

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.

The following example shows how to use the Ticks property to create tick marks along the Slider at irregular intervals.

<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 with Data Binding Sample.

System.Object
  System.Windows.Threading.DispatcherObject
    System.Windows.DependencyObject
      System.Windows.Media.Visual
        System.Windows.UIElement
          System.Windows.FrameworkElement
            System.Windows.Controls.Primitives.TickBar

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 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft