开发者

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

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>开发者_Go百科
  </DataTemplate>        
</UserControl.Resources>

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


Problem solved.

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

Thanks.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜