TextBlock中的内联对象,TextTrimming = CharacterEllipsis或WordEllipsis

时间:2012-09-06 11:33:38

标签: wpf textblock texttrimming

如果您运行此代码并最小化/最大化窗口宽度

<TextBlock TextTrimming="WordEllipsis" >
    <Run Text="I want that this rectangle will be placed "/>
    <Rectangle Fill="Black" Width="20" Height="10" />
    <Run Text=" here when I minimize width of the window"/>
</TextBlock>

您将看到Rectange将向左侧移动的内容。 enter image description here enter image description here

是WPF中的错误吗?

2 个答案:

答案 0 :(得分:0)

我想这不是一个错误。 尝试从文本块中取出TextTrimming="WordEllipsis"属性(它会影响整个控件) 并且你会发现矩形不会随着窗口大小的变化而移动,因为你没有任何HorizentalAligment属性。

答案 1 :(得分:0)

虽然它似乎是一个错误,但这可能是一种解决方法:

<TextBlock TextTrimming="WordEllipsis" >
<Run Text="I want that this rectangle will be placed "/>
<Run Text="&#x25A0;" FontSize="40" BaselineAlignment="Center"/>
<Run Text=" here when I minimize width of the window"/>
</TextBlock>

Unicode Characters in the Geometric Shapes Block

相关问题