This is a migrated thread and some comments may be shown as answers.

Whole numbers only?

3 Answers 243 Views
Slider
This is a migrated thread and some comments may be shown as answers.
Joshua
Top achievements
Rank 2
Joshua asked on 06 Aug 2019, 06:48 PM

I am trying to use the RadSlider to allow the user to choose the number of Millimeters on an interface, I don't need fractions at all, but I can't figure out how to get the RadSlider to snap to whole numbers when they drag the slider.  If anyone has an example of how to do this it would be much appreciated.

thanks!

3 Answers, 1 is accepted

Sort by
0
Joshua
Top achievements
Rank 2
answered on 06 Aug 2019, 08:32 PM

So far it looks like the only way is to override the style, I was just wondering if there were a simpler solution:

 

<telerik:RadSlider.AutoToolTipContentTemplate>
    <DataTemplate>
        <Grid Width="32" Height="44" Background="Transparent">
            <Path Data="M12,6C12,9.3 7.9,13.8 6,16C4.1,13.6 0,9.3 0,6C0,2.6 2.6,0 6,0C9.3,0 12,2.6 12,6z" Fill="{telerik:MaterialResource ResourceKey=PrimaryNormalBrush}" Stretch="Fill"/>
            <TextBlock x:Name="PinText" Text="{Binding .,Converter={StaticResource NumericPrecisionConverter}, ConverterParameter=0}" FontSize="11"
                       Foreground="{telerik:MaterialResource ResourceKey=MarkerInvertedBrush}" Margin="0 12 0 0" HorizontalAlignment="Center"
                       VerticalAlignment="Top" FontWeight="Normal"/>
        </Grid>
    </DataTemplate>
</telerik:RadSlider.AutoToolTipContentTemplate>
1
Accepted
Dilyan Traykov
Telerik team
answered on 08 Aug 2019, 01:05 PM
Hi Joshua,

If I've correctly understood your requirement, I believe you can achieve the desired result by setting the TickFrequency property of the control to 1 and setting the IsSnapToTickEnabled property to True. Here's an example:

<telerik:RadSlider Minimum="1" Maximum="10" IsSnapToTickEnabled="True" TickFrequency="1" />

Could you please give this a try and let me know if it provides the desired functionality?

Regards,
Dilyan Traykov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Joao
Top achievements
Rank 1
commented on 27 Aug 2021, 04:48 PM

Just wanted to say thank you. :)

I just wasn't finding any of this in the documentation.

0
Joshua
Top achievements
Rank 2
answered on 08 Aug 2019, 10:59 PM

Thank you, that does exactly what I was looking for.

Tags
Slider
Asked by
Joshua
Top achievements
Rank 2
Answers by
Joshua
Top achievements
Rank 2
Dilyan Traykov
Telerik team
Share this question
or