I'm trying to bind a rich content (RTF format) to a rich text box (of Extended WPF Toolkit) via its Text property like this
<extToolkit:RichTextBox x:Name="rtbKIContent" Margin="8,8,8,8"
IsEnabled="{Binding IsEditable}"
Text="{Binding Content}">
<extToolkit:RichTextBox.TextFormatter>
<extToolkit:RtfFormatter></extToolkit:RtfFormatter>
</extToolkit:RichTextBox.TextFormatter>
<extToolkit:RichTextBoxFormatBarManager.FormatBar>
<extToolkit:RichTextBoxFormatBar />
</extToolkit:RichTextBoxFormatBarManager.FormatBar>
</extToolkit:RichTextBox>
Sometimes it works just fine, but there are circumstances that they just display the text vertically like this.
I don't know what's wrong with it...What should I do to make it display text from left to right like normal?
If you add a width to the RichTextBox, it should fix it.
I did this so it binds to the parent.
Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Grid, AncestorLevel=1}, Path=ActualWidth}"
Note you will have to determine AncestorType for you. But you can do this too. Width="100"
Agree with "jmogera". Need to set width for this issue.
HorizontalAlignment="Stretch" MinWidth="100"
You can set MinWidth to 100 and keep HorizontalAlign to streach if you want control to resize.
来源:https://stackoverflow.com/questions/9679353/extended-wpf-toolkit-richtextbox-display-text-vertically