none
Problem with TextTrimming of TextBlock

    Question

  • Hi,
    TextTrimming is not working when I put a Text Block inside a Stack Panel which is also a child of another stack panel. Here is my sample code

    <StackPanel Orientation="Vertical">
                <TextBlock Name="TextBlock1" Text=" Hello Friend Here I'am " TextTrimming="WordEllipsis"></TextBlock>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Name="TextBlock2" Text=" Hello Friend Here I'am " TextTrimming="WordEllipsis"></TextBlock>
                    <Image Source="../Images/Image.jpg"></Image>
                    <StackPanel Orientation="Vertical">
                        <TextBlock Name="TextBlock3" Text=" Hello Friend Here I'am " TextTrimming="WordEllipsis"></TextBlock>
                        <TextBlock Name="TextBlock4" Text=" Hello Friend Here I'am " TextTrimming="WordEllipsis"></TextBlock>
                    </StackPanel>
                </StackPanel>
            </StackPanel>

    First Text Block (Name = TextBlock1) is working when I resize the User Control, But the others Text Block TextTrimming is not working.
    Thank you for your valuable inputs.

    Wednesday, May 04, 2011 12:00 PM

Answers

All replies

  • Try assigning the TextBlock a width

    Brice

    Wednesday, May 04, 2011 12:09 PM
  • Hi Brice,

    I've tried with Width property of Text Block. But it won't work at all. Problem is when I place texttrimming property of text block in another stack panel it does not work.

    Thank you for your suggestion.

     

    Wednesday, May 04, 2011 12:43 PM
  • Do you mean in the nested StackPanel in your example? This works for me:

    <UserControl x:Class="TextTrimming.MainPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        d:DesignHeight="300" d:DesignWidth="400">
    
        <Grid x:Name="LayoutRoot" Background="White">
    <StackPanel Orientation="Vertical">
                <TextBlock Name="TextBlock1" Text=" Hello Friend Here I'am " TextTrimming="WordEllipsis"></TextBlock>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Name="TextBlock2" Text=" Hello Friend Here I'am " TextTrimming="WordEllipsis"></TextBlock>
                    <Image Source="../Images/Image.jpg"></Image>
                    <StackPanel Orientation="Vertical">
                        <TextBlock Name="TextBlock3" Text=" Hello Friend Here I'am " Width="50" TextTrimming="WordEllipsis"></TextBlock>
                        <TextBlock Name="TextBlock4" Text=" Hello Friend Here I'am " TextTrimming="WordEllipsis"></TextBlock>
                    </StackPanel>
                </StackPanel>
            </StackPanel>
        </Grid>
    </UserControl>
    

    How does it evaluate on your end?

    Brice

    Wednesday, May 04, 2011 1:20 PM