Can you limit the length of Text visible in a WPF TextBlock?

前端 未结 2 1376
时光说笑
时光说笑 2020-12-21 05:27

I have a listbox that is bound to a database query result. I\'m using an item template that shows the subject on one line and I want it to show preview of the body on anothe

2条回答
  •  时光说笑
    2020-12-21 05:40

    You can use 'TextTrimming' Property of a Textblock. Set TextTrimming = "CharacterEllipsis". You might need to play with Width to manage how many characters you really want to display.

    
    

    Add this textblock in your item template

提交回复
热议问题