I am having a problems with text wrapping in WPF
's RichTextBox
, when I get the text like:
TextRange tr = new TextRange(rtb.Document.ContentStart,
rtb.Document.ContentEnd);
tr.Text
doesnt have any "\\r\\n", but in visual control it looks like it should be (it wraps when input reaches RichTextBox
border (inserts end of the line)).
I create RichTextBox like this:
<RichTextBox Name="Rtb" AcceptsReturn="True" AcceptsTab="True" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Height="100" Margin="15,125,5,45" Width="272">
<FlowDocument LineHeight="1" IsColumnWidthFlexible="true" >
<Paragraph LineStackingStrategy="MaxHeight">
<Run Text="RichTextBox"/>
</Paragraph>
</FlowDocument>
</RichTextBox>
You have to place the RichTextBox in a ScrollViewer.
<ScrollViewer>
<RichTextBox>
...
</RichTextBox>
</ScrollViewer>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.