Whole numbers only?

4 posts, 1 answers
  1. Joshua
    Joshua avatar
    17 posts
    Member since:
    Apr 2018

    Posted 06 Aug 2019 Link to this post

    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!

  2. Joshua
    Joshua avatar
    17 posts
    Member since:
    Apr 2018

    Posted 06 Aug 2019 Link to this post

    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>
  3. Answer
    Dilyan Traykov
    Admin
    Dilyan Traykov avatar
    1190 posts

    Posted 08 Aug 2019 Link to this post

    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.
  4. Joshua
    Joshua avatar
    17 posts
    Member since:
    Apr 2018

    Posted 08 Aug 2019 in reply to Dilyan Traykov Link to this post

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

Back to Top