WPF.如何将 InlineUIContainer 内容中的文本与 RichTextBox 中的外部文本对齐 [英] WPF. How to align text in InlineUIContainer content with outer text in RichTextBox

查看:43
本文介绍了WPF.如何将 InlineUIContainer 内容中的文本与 RichTextBox 中的外部文本对齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任务:使InlineUIContainer的文本内容与外部文本内联

The task: Make the text content of the InlineUIContainer to be inline with the outer text

InlineUIContainer 内容的标准行为是当底部边缘与外部文本内联时.

The standard behaviour of the InlineUIContainer content is when the bottom edge is inline with the outer text.

可以使用 RenderTransform 移动 InlineUIContainer 的内容,但是必须为每种字体类型和大小选择 Y 的值 - 不是一个完美的方法.

It is possible to shift the content of InlineUIContainer with RenderTransform, but the value of Y has to be chosen for each font type and size - not a perfect way.

<RichTextBox>
    <FlowDocument>
        <Paragraph>
            LLL
            <InlineUIContainer>
                <Border Background="LightGoldenrodYellow">
                    <TextBlock Text="LLL"/>
                </Border>
            </InlineUIContainer>
            LLL
        </Paragraph>

        <Paragraph>
            LLL
            <InlineUIContainer>
                <Border Background="LightGoldenrodYellow">

                    <Border.RenderTransform>
                        <TranslateTransform Y="5" />
                    </Border.RenderTransform>

                    <TextBlock Text="LLL"/>

                </Border>    
            </InlineUIContainer>
            LLL
        </Paragraph>
    </FlowDocument>
</RichTextBox>

无论字体类型和大小如何,如何将 InlineUIContainer 内容中的文本与 RichTextBox 中的外部文本对齐?

How to align the text in the InlineUIContainer content with the outer text in RichTextBox regardless of font type and size?

推荐答案

您是否尝试过使用 InlineUIContainer.BaselineAlignment

这里是一些如何使用它的示例

here are some examples for how to use it

这篇关于WPF.如何将 InlineUIContainer 内容中的文本与 RichTextBox 中的外部文本对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆