11

If you run this code and minimize/maximize width of the window

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

you will see what Rectange will shift to the left side. enter image description here enter image description here

Is a bug in the WPF?

Amicable
  • 3,115
  • 3
  • 49
  • 77
Maxim Kapitonov
  • 475
  • 4
  • 9
  • 1
    I did not find anything in the WPF documentation that mentions that InlineUIContainers (such as Rectangles) are exempt from text trimming. Therefore I think it is either a bug in the WPF implementation or an omission in the WPF documentation. I suggest you create a bug report on [Microsoft Connect](http://connect.microsoft.com/). –  Sep 08 '12 at 15:13

2 Answers2

0

I guess this is not a bug. Try to take TextTrimming="WordEllipsis" property off the text block (it affects the whole control) and you will see that the rectangle wont move with you window size changes beacause you dont have any HorizentalAligment properties.

BARAKUDA
  • 23
  • 4
0

While it seems to be a bug, this might be a workaround:

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

See Unicode Characters in the Geometric Shapes Block.

rmojab63
  • 3,513
  • 1
  • 15
  • 28
  • Note that I tried to solve it by putting three ``TextBlock``, one after each other in a ``DockPanel``, but the result was not satisfying. – rmojab63 Feb 18 '17 at 11:28