Intersoft ClientUI Documentation
How-to: Enable Snap to Tick Behavior in UXSliderBar

This example shows how to enable snap to tick behavior in UXSliderBar.

Example

Description

You can enable snap to tick behavior in UXSliderBar using IsSnapToTickEnabled property. When this property is enabled, all user interaction to change the value will be adjusted to the closest tickbar item. When you select a value within a tickbar range, the value will be adjusted and changed to the closest tickbar item. For example, when you select 3.2 as the value of a UXSliderBar that starts from 0 to 10 with LargeChange set to 1, the value will be adjusted to the closest tickbar item, which is 3.

The following code example shows how to enable snap to tick behavior in UXSliderBar. It also shows that this behavior will be ignored when the value of UXSliderBar is set programmatically.

Code

View
Copy Code
private void Button_Click(object sender, RoutedEventArgs e)
{
    uxSlider1.Value = 5.7;
}
            

View
Copy Code
<StackPanel>
    <Button x:Name="Button1" Height="20" Width="200" Content="Change UXSliderBar value" Click="Button_Click"/>
    <Intersoft:UXSliderBar x:Name="uxSlider1" TickPlacement="BottomRight" HandlesVisibility="Visible" IsSnapToTickEnabled="True" />
</StackPanel>
            

When you move UXThumb along UXSliderBar track or invoke UXSliderBar commands by pressing the handle or increase and decrease buttons, the UXThumb will be moved to the closest tickbar item.

When you click the Button1 control, the value of UXSliderBar will be set to 5.7. In this case, the value will not be adjusted to the closest tickbar item because it is not invoked by user interaction.

See Also

Other Resources