Line breaks as I type

2 posts, 0 answers
  1. John
    John avatar
    18 posts
    Member since:
    Mar 2013

    Posted 08 Mar Link to this post

    In an application I work on, a developer has recently added replaced a couple regular Microsoft multiline textboxes with Telerik RichTextBoxes.  In one instance, it works fine.  In another instance the line breaks after several characters so it appears on the UI as typing like:

     This is an
    example of what is happening when typing |


    What may be causing this unintended line break?  This is the code implemented in this instance:

            private const string XamlMultilineTextBox =
                "<telerik:RadRichTextBox xmlns=\"{0}\" xmlns:telerik=\"{1}\" xmlns:x=\'{3}\' xmlns:rtf=\"clr-namespace:Telerik.Windows.Documents.FormatProviders.Txt;assembly=Telerik.Windows.Documents\" x:Name=\"RTFBox\"   Height=\"48\" VerticalScrollBarVisibility=\"Auto\" Margin=\"0\" VerticalContentAlignment=\"Stretch\"  FontFamily=\"Segoe UI\" FontSize=\"12\" FontStyle=\"Normal\" IsSpellCheckingEnabled=\"False\" FontWeight=\"Normal\" DocumentInheritsDefaultStyleSettings=\"True\"><telerik:RadRichTextBox.Resources><rtf:TxtDataProvider x:Key=\"RtfDataProvider\" RichTextBox=\"{{Binding ElementName=RTFBox}}\" Text=\"{{Binding {2}, Mode=TwoWay}}\"  /></telerik:RadRichTextBox.Resources></telerik:RadRichTextBox>";

            private static UIElement BuildMultiLineTextBox(MultilineTextBoxDescriptor descriptor)
                var propertyName = descriptor.PropertyName;
                var output = string.Format(XamlMultilineTextBox, DefaultNamespace, TelerikNamespace, propertyName, winfxNamespace);
                // ReSharper disable JoinDeclarationAndInitializer
                UIElement ctrl;
                // ReSharper restore JoinDeclarationAndInitializer

                ctrl = (UIElement)XamlReader.Load(output);
                ctrl = (UIElement)XamlReader.Parse(output);

                var multilineTextBox = (RadRichTextBox)ctrl;
                multilineTextBox.IsSelectionMiniToolBarEnabled = false;
                multilineTextBox.TabIndex = descriptor.TabIndex;
                multilineTextBox.ShowFormattingSymbols = false;
                multilineTextBox.IsContextMenuEnabled = false;

                                            new Binding
                                                Path =
                                                    new PropertyPath(GetIsReadOnlyPropertyName(descriptor.PropertyName)),
                                                Mode = BindingMode.TwoWay

                                            new Binding
                                                Path =
                                                    new PropertyPath(GetIsVisiblePropertyName(descriptor.PropertyName)),
                                                Mode = BindingMode.TwoWay,
                                                Converter = new BoolToVisibilityConverter(),
                                                ConverterParameter = descriptor.PropertyName

                return ctrl;



    Thank you,

  2. Boby
    Boby avatar
    586 posts

    Posted 11 Mar Link to this post

    Hi John,

    I was not able to reproduce the problem on my side, so I suppose it could be related to a specific styling applied in your application - for example through explicit styles. We have seen similar problems for example when there is implicit styling for TextBlocks - and as RadRichTextBox uses TextBlock to visualize the text lines, inconsistencies could arise.

    Another possibility is that the problem is bound to a specific RadDocument content (as the document contains styles and other properties that could affect the layout). From the sample code you send here, it seems that you are using TxtFormatProvider, so this shouldn't be the problem, but is another clue that can help you trace the issue.

    That said, could you try to isolate the problem in a separate application and send it to us for further investigation? Looking forward to your reply.

    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. DevCraft R3 2016 release webinar banner
Back to Top