The following WPF window is available in .Net Framework 4.0:

<Window x:Class="EasyDiagnost.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300"> <Grid> <ListBox Margin="0" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch"> <RichTextBox> <FlowDocument> <Paragraph> <Run Text="One"/> </Paragraph> </FlowDocument> </RichTextBox> <RichTextBox> <FlowDocument> <Paragraph> <Run Text="Two"/> </Paragraph> </FlowDocument> </RichTextBox> </ListBox> </Grid> </Window> 

Text in RichTextBox is displayed either from left to right, and from top to bottom. How to fix it? Already the whole head broke!

alt text

  • Perhaps, instead of VerticalContentAlignment = "Stretch" for ListBox, you need to set Word Wrapping to true for RichTextBox - Maxim Kamalov
  • RichTextBox has no Word Wrapping option and the like. This is RichTextBox, not TextBox. At least I have not found such a thing - krupennikov

1 answer 1

Perhaps this is a bug at RichTextBox .

It works for me like this:

 <Grid> <ListView x:Name="LV"> <RichTextBox Width="{Binding ActualWidth, ElementName=LV}"> <FlowDocument> <Paragraph>One</Paragraph> </FlowDocument> </RichTextBox> <RichTextBox Width="{Binding ActualWidth, ElementName=LV}"> <FlowDocument> <Paragraph> <Run Text="Two"/> </Paragraph> </FlowDocument> </RichTextBox> </ListView> </Grid> 
  • Thanks again. Did the same thing, but in the code. I thought my head was boiling, but it turned out to be a bug. - krupennikov
  • 3
    In general, there is a vest, where you can cry all the bugs to eliminate them? - krupennikov
  • If I'm not mistaken, the vest is here: visualstudio.uservoice.com/forums/121579-visual-studio/category/… (I even opened one requester). - VladD