Why does this Flow Document take up more space than it needs?
The height of the object is about 60 pixels, but the text is only about 12 pixels tall. I tried setting the Height="30" but then the text wasn't readable.
<RichTextBox IsReadOnly="True" Focusable="False" >
<FlowDocument xml:space=开发者_StackOverflow中文版"preserve" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" >
<Table>
<TableRowGroup>
<TableRow>
<TableCell BorderThickness="0" >
<Paragraph>
<Bold>
<Run Text="test"/>
</Bold>
</Paragraph>
</TableCell>
</TableRow>
</TableRowGroup>
</Table>
</FlowDocument>
</RichTextBox>
Using a paragraph gives you an extra line at the top and the bottom. In code you can do this
Paragraph p = this.rtbCommandLine.Document.Blocks.FirstBlock as Paragraph;
p.LineHeight = 10;
And programmatically add your Runs... I don't know how to do it in XAML
精彩评论