This is a migrated thread and some comments may be shown as answers.

Line breaks as I type

1 Answer 53 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 08 Mar 2016, 08:27 PM

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

#if SILVERLIGHT
            ctrl = (UIElement)XamlReader.Load(output);
#else
            ctrl = (UIElement)XamlReader.Parse(output);
#endif

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


            multilineTextBox.SetBinding(RadRichTextBox.IsReadOnlyProperty,
                                        new Binding
                                        {
                                            Path =
                                                new PropertyPath(GetIsReadOnlyPropertyName(descriptor.PropertyName)),
                                            Mode = BindingMode.TwoWay
                                        });

            multilineTextBox.SetBinding(UIElement.VisibilityProperty,
                                        new Binding
                                        {
                                            Path =
                                                new PropertyPath(GetIsVisiblePropertyName(descriptor.PropertyName)),
                                            Mode = BindingMode.TwoWay,
                                            Converter = new BoolToVisibilityConverter(),
                                            ConverterParameter = descriptor.PropertyName
                                        });

            return ctrl;
        }

 

 

Thank you,
John 

1 Answer, 1 is accepted

Sort by
0
Boby
Telerik team
answered on 11 Mar 2016, 06:39 AM
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.

Regards,
Boby
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
RichTextBox
Asked by
John
Top achievements
Rank 1
Answers by
Boby
Telerik team
Share this question
or