Insert white space of arbitrary width to FlowDocument

送分小仙女□ 提交于 2019-12-14 03:14:19

问题


Is there a way to insert white space of given width to FlowDocument as Inline ? So that I can 'indent' some other Inlines as I want.

If it was possible to place some inline on some x-offset in the line that would also solve the problem.

NOTE: the purpose of this would be solving partial problem of the problem described in this question.


回答1:


You could use the container classes, e.g.:

<RichTextBox>
    <FlowDocument>
        <Paragraph>
            <InlineUIContainer>
                <FrameworkElement Width="200"/>
            </InlineUIContainer>
            <Run x:Name="RunChan" Text="Indented Text"/>
        </Paragraph>
    </FlowDocument>
</RichTextBox>

I would not really recommend it though.


In a TextBlock:

<TextBlock>
    <InlineUIContainer>
        <FrameworkElement Width="200"/>
    </InlineUIContainer>
    <Run x:Name="RunChan" Text="Indented Text"/>
</TextBlock>



回答2:


I'm not sure if this will solve your problem, but if you want to "indent" an Inline, perhaps you can insert a small Floater or Figure sized to what you need. Make sure the Floater is short so that it doesn't span more than a single line.

I'm looking for something more elegant than this myself, but this is working for me in the meanwhile.



来源:https://stackoverflow.com/questions/5796778/insert-white-space-of-arbitrary-width-to-flowdocument

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!