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

南楼画角 提交于 2019-12-05 19:23:32

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...

Try to play with Border.Margin property.. (try to set it to "0,-5,0,-5", or some other numbers)

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