1

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"?

SuicideSheep
  • 5,260
  • 19
  • 64
  • 117

2 Answers2

2

Try this

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

output

enter image description here

Heena
  • 8,450
  • 1
  • 22
  • 40
  • I've tried your way. What happened was there wasn't any "..." but it expand to the next line instead. tes
    ting
    tex
    – SuicideSheep Mar 25 '14 at 10:19
  • run this code separately you will get same result and make sure that you are not using Textwrapping because textrapping will do line break(next line) – Heena Mar 25 '14 at 10:22
1

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

kenjara
  • 402
  • 10
  • 18