I need to display text with colors and formatting in a List. I'm using a ListBox with a RichTextControl to display the data. I also need the contents to size to the window, but the text does not need to wrap.
When I make this simple example the text appears vertical and doesn't change as I size the window. If I set the Width of the RichTextBox to a fixed size like 100 then it works.
Any ideas?
<Window x:Class="WpfApplication19.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 HorizontalContentAlignment="Stretch">
<ListBox.Items>
<RichTextBox>
<FlowDocument>
<Paragraph>
<Run>this is a test</Run>
</Paragraph>
</FlowDocument>
</RichTextBox>
</ListBox.Items>
</ListBox>
</Grid>
</Window>
If there is a better option for displaying text were parts of the text are different colors please let me know.