5

How come TextTrimming works on the first TextBlock and NOT on the second one? I am using LineBreaks on my xaml, which is part of the text I need to display.

Code:

<Window x:Class="WpfApplication2.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">
<Grid VerticalAlignment="Center">
    <StackPanel>
        <TextBlock TextTrimming="WordEllipsis" TextWrapping="Wrap" Width="20" Height="20" Background="Yellow">
            1 2 3 4 5
        </TextBlock>

        <TextBlock TextTrimming="WordEllipsis" TextWrapping="Wrap" Width="20" Height="20" Background="Aqua">
            1
            <LineBreak/>
            2
            <LineBreak/>
            3
            <LineBreak/>
            4
            <LineBreak/>
            5
        </TextBlock>
    </StackPanel>
</Grid>

Output:

enter image description here

Flip Booth
  • 271
  • 3
  • 11
  • Is it because each number is on a new line in the second example thus no need to WordEllipsis – sa_ddam213 Aug 29 '14 at 04:03
  • You just kinda repeated my question. – Flip Booth Aug 29 '14 at 04:24
  • Not Really, you have 5 lines in the second one, none of those lines ate longer than the TextBlock so no ellipsis is applied, setting the TextBlock height will not modify the string and remove the linebreaks making it one line that is longer than the textblock. – sa_ddam213 Aug 29 '14 at 04:31
  • So, as I have asked, it is per LINE, not per TextProperty? – Flip Booth Aug 29 '14 at 04:32

1 Answers1

0

You are misunderstanding what it means to trim. Trim deals with line length. Your second example has a short line length, but has a lot of lines. This is different from having a long line length.

Thus trimming is not what you need.

Mashton
  • 6,037
  • 2
  • 25
  • 35
  • 4
    what is the solution? Trimming is what I need but in a different way. If paragraph cannot fit inside the textblock, I want it to have the ellipsis – Flip Booth Aug 29 '14 at 15:35