开发者

Cutting off Text in Silverlight

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>


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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜