Silverlight - TextWrapping WordEllipsis not working within Grid with no fixed width

938 Views Asked by At

The following grid and container(s) do not have a fixed width.

I'm trying to force the text within TextBlock controls to be trimmed with an ellipsis.

The text is not trimmed, instead the entire text is displayed which goes outside the width of the silverlight application.

The issue seems to be related to the fact there is no fixed width for the grid or it's container(s). As soon as I configure a width, the text is trimmed as desired.

Has anyone experienced this issue? Is there a way of getting the text to trim?

Thanks in advance.

<UserControl.Resources>
  <DataTemplate x:Key="ExampleTemplate">
    <Grid>
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="0.3*"/>
        <ColumnDefinition Width="0.3*"/>
        <ColumnDefinition Width="0.4*"/>
      </Grid.ColumnDefinitions>

      <TextBlock Grid.Column="0" Text="Long text here - blah blah blah blah blah blah blah blah blah blah blah blah" TextTrimming="WordEllipsis" />
      <TextBlock Grid.Column="1" Text="Long text here - blah blah blah blah blah blah blah blah blah blah blah blah" TextTrimming="WordEllipsis" />
      <TextBlock Grid.Column="2" Text="Long text here - blah blah blah blah blah blah blah blah blah blah blah blah" TextTrimming="WordEllipsis" />
    </Grid>
  </DataTemplate>        
</UserControl.Resources>

<ScrollViewer>
  <ItemsControl  ItemTemplate="{StaticResource ExampleTemplate}" ItemsSource="{Binding ExampleRows}"/>
</ScrollViewer>
1

There are 1 best solutions below

0
On BEST ANSWER

Problem solved.

The ScrollViewer 'HorizontalScrollBarVisibility' property was set to 'Hidden', the property should have been set to 'Disabled'.

Thanks.