问题
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>
How to align the text in the InlineUIContainer content with the outer text in RichTextBox regardless of font type and size?
回答1:
have you tried playing around with InlineUIContainer.BaselineAlignment
here are some examples for how to use it
来源:https://stackoverflow.com/questions/5225268/wpf-how-to-align-text-in-inlineuicontainer-content-with-outer-text-in-richtextb