Skip to content

RichTextBox throws XamlParseException in its constructor #1178

@Nukepayload2

Description

@Nukepayload2
  • .NET Core Version: 3.0 preview 6
  • Windows version: Windows 10 x64 zh-CN 18362.207
  • Does the bug reproduce also in WPF for .NET Framework 4.8?: No

Problem description:
The constructor of RichTextBox crashes when running on Windows 10 1903 Chinese Simplified.
Similar to #1003

Actual behavior:
($exception).StackTrace

 An unhandled exception of type 'System.Windows.Markup.XamlParseException' occurred in System.Private.CoreLib.dll
“对类型“System.Windows.Controls.RichTextBox”的构造函数执行符合指定的绑定约束的调用时引发了异常。”,行号为“10”,行位置为“10”。

DirectCast(($exception)._innerException, System.ArgumentException).Message

Requested value '删除' was not found.

($exception)._innerException.StackTrace

   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 MS.Internal.Commands.CommandHelpers.RegisterCommandHandler(Type controlType, RoutedCommand command, ExecutedRoutedEventHandler executedRoutedEventHandler, CanExecuteRoutedEventHandler canExecuteRoutedEventHandler, String srid1, String srid2)
   at System.Windows.Documents.TextEditorTyping._RegisterClassHandlers(Type controlType, Boolean registerEventListeners)
   at System.Windows.Documents.TextEditor.RegisterCommandHandlers(Type controlType, Boolean acceptsRichContent, Boolean readOnly, Boolean registerEventListeners)
   at System.Windows.Controls.RichTextBox..ctor(FlowDocument document)
   at System.Windows.Baml2006.WpfSharedBamlSchemaContext.<>c.<Create_BamlType_RichTextBox>b__923_0()
   at System.Windows.Baml2006.WpfKnownTypeInvoker.CreateInstance(Object[] arguments)
   at MS.Internal.Xaml.Runtime.ClrObjectRuntime.CreateInstanceWithCtor(XamlType xamlType, Object[] args)
   at MS.Internal.Xaml.Runtime.ClrObjectRuntime.CreateInstance(XamlType xamlType, Object[] args)

Expected behavior:
RichTextBox should not throw exception.

Minimal repro:
Drag a RichTextBox control into MainWindow.xaml.

<Window x:Class="MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:RichTextTest"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
        <RichTextBox/>
    </Grid>
</Window>

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugProduct bug (most likely)

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions