How to get a Slider to stop at discreet points on a Windows Phone app

By default the Slider control that Microsoft provides for Windows Phone Silverlight applications is missing some key properties such as the IsSnapToTickEnabled property. However this can be recreated in code to give Windows Phone apps the same functionality.

First the XAML…

<Slider x:Name="slider" Width="450" ValueChanged="Slider_ValueChanged" Minimum="0" Maximum="10" SmallChange="1"/>

Then in C#…

public void Slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e)
            int newValue = (int)e.NewValue;
            slider.Value = newValue;

            //code goes here, using newValue
            //as the slider's value...
        catch (Exception) { }