tags:

views:

24

answers:

1

I'm trying to use what's below as a DataTemplate for items bound in a ListBox. It looks fine, except for the text in the "Title" textbox. It truncates, just as it's supposed to, but for those titles that are long enough to be truncated, the very right edge, right where the text is being cut off, is colored slightly funky - sort of an orange-like color.

Does this have something to do with the way fonts are represented - with some sort of layering in the font itself that might be getting disturbed by Silverlight chopping it off?

I've tried messing around with margins, to see if that would somehow help, but it did not.

    <DataTemplate x:Key="BookDataTemplateSmall">
        <Border CornerRadius="3" BorderThickness="2" BorderBrush="Black">
            <Grid Margin="3">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="60"></ColumnDefinition>
                    <ColumnDefinition Width="250"></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <Image Grid.Column="0" x:Name="imgSmall" Stretch="Fill" Source="{Binding Path=SmallImgURI}" Margin="7,0,0,0" Cursor="Hand"></Image>
                <StackPanel HorizontalAlignment="Left" Grid.Column="1" Margin="5,0,10,0">
                    <TextBlock Foreground="Black" ToolTipService.ToolTip="{Binding Path=CurrentBook.Title}" Width="240" Text="{Binding Path=CurrentBook.Title}"></TextBlock>
                    <TextBlock Text="{Binding Path=CurrentBook.Published, StringFormat=d}"></TextBlock>
                </StackPanel>
            </Grid>
        </Border>
    </DataTemplate>
+2  A: 

It might help to use the TextBlock.TextTrimming property

Try setting it to

System.Windows.TextTrimming.WordEllipsis;

OR

System.Windows.TextTrimming.CharacterEllipsis;

Take a look at this page for more information.

Gabriel McAdams
That worked. I just wish the ellipsis wasn't so "greedy" - there's clearly room for an extra word or two, but hey, it's better than the weird-color clipping. Thanks.
Adam