SuicideSheep
SuicideSheep

Reputation: 5550

Textblock modify text automatically

Let's say I have two TextBlock on the same page and both binding to the same variable:

<TextBlock Text={Binding [someViewModel].someText}/>
<TextBlock Text={Binding [someViewModel].someText}/>

//someText = "testingText"

I'm wondering if it's possible to have the first textblock to show "tes......" and the second textblock showing "testingText"?

Upvotes: 1

Views: 72

Answers (2)

Heena
Heena

Reputation: 8634

Try this

 <StackPanel>
    <TextBlock Text="testingtext" MaxWidth="20" TextTrimming="CharacterEllipsis" HorizontalAlignment="Left"></TextBlock>
    <TextBlock Text="testingtext" ></TextBlock>
 </StackPanel>

output

enter image description here

Upvotes: 2

kenjara
kenjara

Reputation: 402

Make an IValueConverter for one of the bindings which converts the String to the custom format you want.

Upvotes: 1

Related Questions