开发者

Why does this Flow Document take up more space than it needs?

开发者 https://www.devze.com 2023-04-13 07:08 出处:网络
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.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号