I've got a value that I want to change with a slider. It can vary from 1 to 100 and I'd like it to increment and decrement in steps of 0.1, but at the moment when I move the slider it changes the value in what's effectively a continuous manner.
This means that the value changes from 10 to 10.04589455 (say) which a) is meaningless for my application and b) ruins the layout of the page.
The `LargeChange` and `SmallChange` properties don't seem to affect this.
I can't round the value in the property setter as I'm binding to a property on an Entity, plus it seems to be the wrong approach for the problem.
How can I achieve this within the slider itself?
I got round this by adding an `IValueConverter` to the `Value` binding:
Value="{Binding NewPageTemplate.LabelHeight, Mode=TwoWay, Converter={StaticResource LabelSizeConverter}}"
This is defined as:
public class LabelSizeConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return value; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { double size = (double)value; return Math.Round(size, 1); } }
Hello Chris,
Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this as well.
Thanks again.