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 position of InlineUIContainer with RenderTransform, but the value of Y has to be chosen for each font type and size - not a perfect way.
<RichTextBox>
<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>
</RichTextBox>
How to align the text in the InlineUIContainer content with the outer text in RichTextBox regardless of font type and size?
In WPF the property BaselineAlignment="Center" works fine.
But Silverlight seems lucking that functionality.
I fined i perfect way around (you can make a custom control from this):
First of all wrap your object into the Canvas...
<Paragraph>LLL
<InlineUIContainer>
<Canvas x:Name="c" LayoutUpdated="c_LayoutUpdated">
<Border Background="LightGoldenrodYellow">
<TextBlock x:Name="t" FontSize="32" Text="LLL"/>
</Border>
</Canvas>
</InlineUIContainer> LLL
</Paragraph>
And add LayoutUpdated event handler to Canvas
private void c_LayoutUpdated(object sender, EventArgs e)
{
c.Width = t.DesiredSize.Width;
c.Height = (t.DesiredSize.Height / 1.3d);
}
After pressing F5 you have to see a miracle :)
PS: Now text do as you wish... no mather what FontStyle and FontSize you use...