TextTrimming with Ellipsis and a Colon

FZdev picture FZdev · Mar 9, 2012 · Viewed 33.2k times · Source

This is a relatively simple question:

I can trim a text with ellipsis using this:

<TextBlock Text="{Binding}" TextTrimming="CharacterEllipsis"/>

it would give me something along the lines of:

"This sentence is too long"

=>

"This sentence i..."

That's all great and dandy, but what I actually want is this:

"This sentence ...:" / "This sentence...:"

What I'm looking for is a colon after the ellipses. Is there a simple way to achieve this?

EDIT:

sorry for the confusion.

I want to change the default ellipsis string from '...' to '...:'. As well, I'm going to include a colon in the text string itself. This way, I'll always have the colon displayed. As well, everything should be on one line in every situation.

here are a couple of results that are acceptable:

short enough:

way too l...:

Answer

Phil picture Phil · Mar 9, 2012

This works, but I needed to add some padding so that the colon always remains visible:

<TextBlock Padding="0,0,5,0" >
    <TextBlock TextTrimming="CharacterEllipsis">Lorem ipsum dolor sit amet, consectetur adipisicing </TextBlock>
    <TextBlock>:</TextBlock>
</TextBlock>