How do you make a WPF slider snap only to discrete integer positions?
问题 All too often I want a WPF slider that behaves like the System.Windows.Forms.TrackBar of old. That is, I want a slider that goes from X to Y but only allows the user to move it in discrete integer positions. How does one do this in WPF since the Value property on the Slider is double? 回答1: If you set your tick marks in the right way, you can use IsSnapToTickEnabled . This worked pretty well for me. See MSDN for details. 回答2: The simple answer is that you take advantage of the