From 1e2697c3058583cd0cf43d95e2cda0d319fe90cb Mon Sep 17 00:00:00 2001 From: Simon Ensslen Date: Thu, 24 Oct 2024 17:08:42 +0200 Subject: [PATCH] Make sure to only use characters that make up a number when parsing the value for a numeric up/down --- .../NumericUpDown/Implementation/CommonNumericUpDown.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/NumericUpDown/Implementation/CommonNumericUpDown.cs b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/NumericUpDown/Implementation/CommonNumericUpDown.cs index 8fb54e58..fa0464c1 100644 --- a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/NumericUpDown/Implementation/CommonNumericUpDown.cs +++ b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/NumericUpDown/Implementation/CommonNumericUpDown.cs @@ -19,6 +19,7 @@ using System.Windows; using System.Globalization; using System.IO; using System.Linq; +using System.Text.RegularExpressions; namespace Xceed.Wpf.Toolkit { @@ -262,7 +263,9 @@ namespace Xceed.Wpf.Toolkit return this.Value; } - result = this.ConvertTextToValueCore( currentValueText, text ); + var cleanedText = Regex.Replace(text, "[^0-9.,]", "", RegexOptions.Compiled, TimeSpan.FromMilliseconds(100)); + + result = this.ConvertTextToValueCore( currentValueText, cleanedText ); if( this.ClipValueToMinMax ) {