Search code examples
c#wpfxamlrichtextboxword-wrap

Disable WPF RichTextBox text auto wrapping


I am using RichTexbox to display RTF text in my application, depends on windows width RichTextbox text auto wraps to next line!!

I want to disable the text auto warp, instead i want to display scroll bar, Also i don't want to set PageWidth of the FlowDocument to avoid text wrapping (since am displaying RTF text i cant measure the PageWidth based on character/size/Font/Font style of the text because each and every character may contains different font style and size)

 <RichTextBox HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">      
   <FlowDocument >
        <Paragraph>
            <Run Text="RichTextBoxRichTextBoxRichTextBoxRichTextBoxRichTextBoxRichTextBoxRichTextBoxRichTextBoxRichTextBoxRichTextBoxRichTextBoxRichTextBoxRichTextBoxRichTextBoxRichTextBoxRichTextBoxRichTextBoxRichTextBoxRichTextBoxRichTextBoxRichTextBox"/>
        </Paragraph>
   </FlowDocument>

Is there any other existing property is there to control auto wrapping or can we handle this without measure text size

I have already discussed about this in MSDN forum also reffered existing stackflow disussions WPF RichTextBox word wrapping and Wpf RichTextBox wrapping problems

Thank you

Santhosh Devi


Solution

  • Third partycontrol syncfusion control SfRichTextBoxAdv has a solution for this issue