Execution stack:
System.FormatException: String was not recognized as a valid DateTime.
at System.DateTime.Parse(String s, IFormatProvider provider)
at Xceed.Wpf.Toolkit.DateTimeUpDown.TryParseDateTime(String text, DateTime& result)
at Xceed.Wpf.Toolkit.DateTimeUpDown.IsCurrentValueValid()
at Xceed.Wpf.Toolkit.Core.Primitives.DateTimeUpDownBase`1.OnPreviewKeyDown(KeyEventArgs e)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
at System.Windows.Interop.HwndKeyboardInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawKeyboardActions actions, Int32 scanCode, Boolean isExtendedKey, Boolean isSystemKey, Int32 virtualKey)
at System.Windows.Interop.HwndKeyboardInputProvider.ProcessKeyAction(MSG& msg, Boolean& handled)
at System.Windows.Interop.HwndSource.CriticalTranslateAccelerator(MSG& msg, ModifierKeys modifiers)
at System.Windows.Interop.HwndSource.OnPreprocessMessage(Object param)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
Comments: ** Comment from web user: BoucherS **
Hi,
Thanks for the sample and the screenshots of the Regions settings.
This should be fixed in v2.7.
In the meantime, you can go in file "Xceed.Wpf.Toolkit/DatetimeUpDown/Implementation/DateTimeUpDown.cs, "
in method "TryParseDateTime",
replace the 2 lines :
```
DateTime current = this.Value.HasValue ? this.Value.Value : DateTime.Parse( this.ContextNow.ToString(), this.CultureInfo.DateTimeFormat );
isValid = DateTimeParser.TryParse( text, this.GetFormatString( Format ), current, this.CultureInfo, out result );
```
with :
```
result = this.ContextNow;
DateTime current = this.ContextNow;
if( this.Value.HasValue )
{
current = this.Value.Value;
}
else
{
try
{
current = DateTime.Parse( this.ContextNow.ToString(), this.CultureInfo.DateTimeFormat );
isValid = DateTimeParser.TryParse( text, this.GetFormatString( Format ), current, this.CultureInfo, out result );
}
catch( FormatException )
{
isValid = false;
}
}
```
and see if its better for your scenario.