Home  separator  Controls  separator  Slider
Bookmark and Share Share...    Subscribe to this feed Feed   About me...


WPF Slider Control

How to Make a Slider Snap to Integer Values

If you just set the Minimum and Maximum of a slider and choose a value the result is determined by the pixel position of the thumb. The value is typically a high-precision value with many decimal places. To allow only integer values you have to set the IsSnapToTickEnabled property to True.

<Slider Minimum="0"
        Maximum="20"
        IsSnapToTickEnabled="True"
        TickFrequency="2"
 



 Comments on this article

Show all comments
Rick Hard...
Commented on 11.August 2009
This simply will not compile in eclipse. Waste of time.
Mark
Commented on 12.August 2009
Rick, you could try using common sense and adding the missing '>' yourself, don't you think?
Nick
Commented on 13.August 2009
Ahem.. '/>' actually.. ;)
Nithin
Commented on 27.August 2009
Why u people kidding a good guy...
Mick
Commented on 17.November 2009
isn't this just a snippet anyways... This broke my cobol
David
Commented on 22.December 2009
rofl
su
Commented on 5.January 2010
Here, this should work:

<Slider Minimum="0" Maximum="20" IsSnapToTickEnabled="True" TickFrequency="2"> </Slider>
Rushin
Commented on 1.February 2010
Dont u criticize people idiotic mark
Navneet
Commented on 1.February 2010
Dont u criticize people idiotic mark
nash
Commented on 10.March 2010
what r u doin man, this is rubbish
karthik
Commented on 26.March 2010
Hai,if anybody can send me the tutorial of wpf for beginners
Nithin
Commented on 6.May 2010
sure, go here: http://www.wpftutorial.net
Daniel
Commented on 11.August 2010
Im not agree with criticize people, but Im agree with Mark, this missing /> its a very simple error. If you read the previus topics of this tutorial you should correct it by yourself.

Name
E-Mail (optional)
Comment
About Christian Moser