WPF. How to align text in InlineUIContainer content with outer text in RichTextBox

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

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

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>

Example

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

6
задан Vadim Loboda 9 March 2011 в 07:07
поделиться