Skip to content

Culture de-DE issue with DataGrid #913

Closed
@Lakritzator

Description

@Lakritzator
  • .NET Core Version: 3.0.100-preview7-012343

  • Windows version: Windows 10 1903 & Windows 7 (6.1 build 7601 Service Pack 1)

  • Does the bug reproduce also in WPF for .NET Framework 4.8?: No

Problem description:
When the UI Culture is de-DE, any interaction (wheel, click) with a DataGrid will throw an exception (see below). This is related to #684

Actual behavior:

Unhandled exception. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: Requested value 'BILDAUF' was not found.
   at System.Enum.TryParseByName(RuntimeType enumType, String originalValueString, ReadOnlySpan`1 value, Boolean ignoreCase, Boolean throwOnFailure, UInt64& result)
   at System.Enum.TryParseInt32Enum(RuntimeType enumType, String originalValueString, ReadOnlySpan`1 value, Int32 minInclusive, Int32 maxInclusive, Boolean ignoreCase, Boolean throwOnFailure, TypeCode type, Int32& result)
   at System.Enum.TryParse(Type enumType, String value, Boolean ignoreCase, Boolean throwOnFailure, Object& result)
   at System.Enum.Parse(Type enumType, String value, Boolean ignoreCase)
   at System.Windows.Input.KeyConverter.GetKey(String keyToken, CultureInfo culture)
   at System.Windows.Input.KeyConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object source)
   at System.Windows.Input.KeyGestureConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object source)
   at System.ComponentModel.TypeConverter.ConvertFromInvariantString(String text)
   at System.Windows.Input.KeyGesture.CreateFromResourceStrings(String keyGestureToken, String keyDisplayString)
   at System.Windows.Input.KeyGesture.AddGesturesFromResourceStrings(String keyGestures, String displayStrings, InputGestureCollection gestures)
   at System.Windows.Input.ComponentCommands.LoadDefaultGestureFromResource(Byte commandId)
   at System.Windows.Input.RoutedCommand.GetInputGestures()
   at System.Windows.Input.RoutedCommand.get_InputGesturesInternal()
   at System.Windows.Input.CommandBindingCollection.FindMatch(Object targetElement, InputEventArgs inputEventArgs)
   at System.Windows.Input.CommandManager.TranslateInput(IInputElement targetElement, InputEventArgs inputEventArgs)
   at System.Windows.UIElement.OnMouseWheelThunk(Object sender, MouseWheelEventArgs e)
   at System.Windows.Input.MouseWheelEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.RouteItem.InvokeHandler(RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.EventRoute.InvokeHandlers(Object source, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
   at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at System.Windows.Window.ShowHelper(Object booleanBox)
   at System.Windows.Window.Show()
   at System.Windows.Window.ShowDialog()
   at Caliburn.Micro.WindowManager.ShowDialog(Object rootModel, Object context, IDictionary`2 settings)

Expected behavior:
No exception

Minimal repro:
https://github.com/Lakritzator/WpfDataGridCultureBug
In fact this is just a "dotnet new wpf", making sure the Thread.CurrentThread.CurrentUICulture is set to the "de-DE" culture, and change the grid in MainWindow.xaml to DataGrid.
Run the example, and use the scrollwheel (or click) on the DataGrid.

I was going to supply a PR, but I'm confused! In #796 the translations are reverted and seem to be okay.

But in the final file https://github.com/dotnet/wpf/blob/master/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Resources/xlf/Strings.de.xlf#L2952 there are still translations which probably cause the issue.

And somehow I don't know where the changes come from...

Maybe @ryalanms knows what happened here.

Metadata

Metadata

Assignees

Labels

BugProduct bug (most likely)

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions