I have a WPF with a RichTextBox. Text inside de RichTextBox doesn't fit the box and is not displayed. I would like text to return to a new line when the end of line is reached.
There are many question related like this question on StackOverflow or this blog but I am surprised I can't apply them: Text Wrapping seems to be native - but it doesn't for me. And there are functions that doesn't exist like myRTBox.WordWrap is not available ?
Are there different types of RichTextBox (I use System.Windows.Controls.RichTextBox)? If not do you have an idea to force wrapping ?
public partial class UserControl1 : System.Windows.Controls.UserControl
{
public UserControl1()
{
InitializeComponent();
RTBox.Document.Blocks.Clear();
RTBox.AppendText("a long message to test how it will be displayed in a rich text box");
...
and the xaml
<RichTextBox x:Name="RTBox" IsReadOnly="True " HorizontalAlignment="Left" Height="65" Margin="12,16,0,0" VerticalAlignment="Top" Width="168" Background="#AAEA900F" HorizontalScrollBarVisibility="Disabled">
<FlowDocument Language="en-us">
<Paragraph>
<Run Text="Test to display a text larger than a single line"/>
</Paragraph>
</FlowDocument>
</RichTextBox>