WPF Standard Control Demo App › Slider

Slider Inputs

Slider is a control that allows users to select a value from a continuous or stepped range by dragging a thumb along a track. It is commonly used for volume controls, zoom levels, opacity settings, and other range-based inputs where visual feedback is important.

Overview

The WPF Slider control inherits from RangeBase, sharing its Minimum, Maximum, and Value properties with ProgressBar. The thumb โ€” the draggable element โ€” moves proportionally between the minimum and maximum bounds, and the Value property reflects the current position as a double. Data-binding Value two-way to a ViewModel property is the standard approach for integrating Slider into MVVM applications.

Slider supports both continuous and discrete (snapped) value selection. Setting IsSnapToTickEnabled="True" combined with TickFrequency restricts the value to multiples of the tick interval, turning the slider into a stepped selector. You can also provide a custom Ticks collection (DoubleCollection) for irregular snap points rather than evenly spaced ones.

Tick marks are rendered on the slider track when TickPlacement is set to TopLeft, BottomRight, or Both. The spacing between rendered ticks is controlled by TickFrequency, while the optional selection range indicator (a highlighted section of the track between SelectionStart and SelectionEnd) visualizes a sub-range within the overall scale โ€” useful for showing valid ranges or target zones.

An auto-tooltip can be enabled via AutoToolTipPlacement, which shows the current numeric value in a tooltip while the user drags the thumb. The number of decimal places displayed is controlled by AutoToolTipPrecision. This provides immediate numeric feedback without requiring a separate TextBlock bound to Value.

Screen Preview

slider demo screen

Demonstrated Properties

The following properties are demonstrated interactively in the WPF Standard Control Demo App. Each property can be configured in real time within the app to observe its behavior.

Property Values Description
Minimum / Maximum / Value (RangeBase) double Defines the range of selectable values and the current position. Use this for continuous inputs such as volume (0โ€“100), zoom (10โ€“400%), or opacity (0.0โ€“1.0). Value is always clamped between Minimum and Maximum. Bind Value two-way to a ViewModel property to read or set the slider position programmatically. Pitfall: setting Maximum < Minimum raises a validation error. When binding both properties dynamically, set Minimum before (or simultaneously with) Maximum to avoid a transient invalid state.
Orientation Horizontal / Vertical Sets the slider's layout direction. Horizontal (default) increases value left-to-right; Vertical increases value bottom-to-top by default. Use IsDirectionReversed to flip the direction if needed. Pitfall: for a vertical slider where large values should be at the top (e.g., audio fader), set IsDirectionReversed="True" โ€” without this, the maximum is at the bottom, which is counterintuitive for most designs.
SmallChange / LargeChange double SmallChange is the value increment for arrow-key navigation; LargeChange is the increment for Page Up/Down. Set these to meaningful domain units (e.g., 1 for integer steps, 0.1 for fine-grained floats) for keyboard accessibility. Pitfall: values too close to the full range make keyboard fine-tuning impossible. For a 0โ€“100 volume slider, SmallChange=1 and LargeChange=10 is appropriate; overly large values lock users into coarse steps.
IsDirectionReversed bool When true, reverses the value direction so the maximum is at the left (horizontal) or top (vertical). Useful for scenarios like a thermometer where higher values are visually at the top, or an audio balance control. Pitfall: reversing the direction does not automatically flip custom tick labels โ€” if you have a Ticks-based label overlay, the labels must be manually reordered to match the reversed direction.
TickPlacement None / TopLeft / BottomRight / Both Controls where tick marks are rendered relative to the track. Use this when visual step indicators improve usability โ€” for example, showing 0/25/50/75/100 marks on a volume slider. Pitfall: TickPlacement only controls rendering; it does not enable snap-to-tick behavior. Set IsSnapToTickEnabled="True" separately to make the thumb snap to tick positions.
TickFrequency double The interval between rendered tick marks and snap positions (when IsSnapToTickEnabled is true). A value of 10 on a 0โ€“100 slider creates ticks at 0, 10, 20, โ€ฆ, 100. Pitfall: if TickFrequency does not evenly divide the range, the last tick will not coincide with Maximum (e.g., Minimum=0, Maximum=100, TickFrequency=30 gives ticks at 0, 30, 60, 90 โ€” the 100 mark is missing).
IsSnapToTickEnabled bool When true, restricts Value to positions defined by tick marks (from TickFrequency or the custom Ticks collection). The thumb snaps to the nearest valid position on drag release. Pitfall: with TickFrequency=1 on a 0โ€“100 slider, only integers can be selected. If your scenario requires float precision (e.g., 0.5), keep IsSnapToTickEnabled="False".
Ticks DoubleCollection An explicit list of tick positions. When provided, ticks are drawn only at these values rather than at uniform TickFrequency intervals. Useful for non-linear scales or labeled breakpoints such as font sizes (8, 9, 10, 11, 12, 14, 16).
SelectionStart / SelectionEnd / IsSelectionRangeEnabled double / double / bool Highlights a sub-range on the track between SelectionStart and SelectionEnd when IsSelectionRangeEnabled is true. Useful for showing valid or recommended value zones on the slider track.
AutoToolTipPlacement None / TopLeft / BottomRight Enables a tooltip showing the current numeric value while dragging โ€” useful when exact values matter, such as zoom percentage or volume level. TopLeft positions the tooltip above (horizontal) or to the left (vertical) of the thumb. Pitfall: the tooltip only shows the raw number with decimal precision controlled by AutoToolTipPrecision. Custom formats (e.g., "50%" or "120 bpm") are not supported. Use a separate TextBlock bound to Value with a StringFormat for custom displays.
AutoToolTipPrecision int The number of decimal places displayed in the auto-tooltip. Set to 0 for integer display, or higher for floating-point precision feedback. Pitfall: setting AutoToolTipPrecision=0 truncates the display to integers even when the actual Value is a float. The displayed value may differ from the stored value if IsSnapToTickEnabled is false.
Delay / Interval int (ms) Controls the repeat behavior when the user clicks on the track (not the thumb) to move the slider by LargeChange increments. Delay is the initial pause before repeating; Interval is the time between repeat steps.

XAML Example

A volume-style slider from 0 to 100 with tick marks, snap-to-tick, and an auto-tooltip:

<Slider Minimum="0" Maximum="100" Value="{Binding Volume, Mode=TwoWay}"
        Orientation="Horizontal"
        TickPlacement="BottomRight" TickFrequency="10"
        IsSnapToTickEnabled="True"
        AutoToolTipPlacement="TopLeft" AutoToolTipPrecision="0"
        SmallChange="1" LargeChange="10"
        Width="300" />

<!-- Vertical slider with reversed direction (max at top) -->
<Slider Orientation="Vertical" Minimum="0" Maximum="1"
        Value="{Binding Opacity, Mode=TwoWay}"
        IsDirectionReversed="True"
        Height="200" />

Common Use Cases

Tips and Best Practices

Related Controls

Source Code

The source code for this demo screen is available on GitHub. Use the built-in code view buttons in the app to see the exact XAML for each property.

View Slider source code on GitHub →