diff --git a/Fluent.Ribbon/Controls/Spinner.cs b/Fluent.Ribbon/Controls/Spinner.cs index c6c292633..3b5180b42 100644 --- a/Fluent.Ribbon/Controls/Spinner.cs +++ b/Fluent.Ribbon/Controls/Spinner.cs @@ -491,7 +491,8 @@ private void OnTextBoxPreviewKeyDown(object sender, KeyEventArgs e) private void TextBoxTextToValue() { - var newValue = (double)this.TextToValueConverter.Convert(this.textBox.Text, typeof(double), this.Value, CultureInfo.CurrentCulture); + var converterParam = new Tuple(this.Format, this.Value); + var newValue = (double)this.TextToValueConverter.Convert(this.textBox.Text, typeof(double), converterParam, CultureInfo.CurrentCulture); this.Value = GetLimitedValue(this, newValue); diff --git a/Fluent.Ribbon/Converters/SpinnerTextToValueConverter.cs b/Fluent.Ribbon/Converters/SpinnerTextToValueConverter.cs index 597c620e6..16a3ff3e1 100644 --- a/Fluent.Ribbon/Converters/SpinnerTextToValueConverter.cs +++ b/Fluent.Ribbon/Converters/SpinnerTextToValueConverter.cs @@ -9,7 +9,11 @@ public class SpinnerTextToValueConverter : IValueConverter { public virtual object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - return this.TextToDouble((string)value, (double)parameter, culture); + var converterParam = (Tuple)parameter; + var format = converterParam.Item1; + var previousValue = converterParam.Item2; + + return this.TextToDouble((string)value, format, previousValue, culture); } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) @@ -17,7 +21,7 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu return this.DoubleToText((double)value, (string)parameter, culture); } - public virtual double TextToDouble(string text, double previousValue, CultureInfo culture) + public virtual double TextToDouble(string text, string format, double previousValue, CultureInfo culture) { // Remove all except digits, signs and commas var stringBuilder = new StringBuilder();