#1,021 – Two Ways to Position Tick Marks on a Slider

You can cause tick marks to be displayed with a Slider control by setting the TickPlacement property.  By default, this places tick marks every 1 unit between the Minimum and Maximum values (inclusive).

There are two ways to change where tick marks are displayed on the Slider.  The first is to set the TickFrequency to indicate the desired spacing between tick marks.  When you set TickFrequency:

  • Tick mark is displayed at Minimum value
  • Tick marks are displayed at Minimum + TickFrequency and then every TickFrequency units
  • Tick mark is displayed at Maximum value

For example, if Minimum is 1, Maximum is 10, and TickFrequency is 2, we get tick marks at: 1, 3, 5, 7, 9, 10.

1021-001

The second method for configuring tick marks is to list a series of positions using the Ticks property.  Ticks are placed at the specified locations, as well as the Minimum and Maximum location.

        <Slider Minimum="1" Maximum="10"
                IsSnapToTickEnabled="True"
                TickPlacement="BottomRight"
                Ticks="2,4,6,8"/>

1021-002

Advertisement