WPF ListView 字符串开头的省略号 [英] Ellipsis at start of string in WPF ListView

查看:26
本文介绍了WPF ListView 字符串开头的省略号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 WPF ListView (GridView) 并且单元格模板包含一个 TextBlock.如果我在 TextBlock 上添加:TextTrimming="CharacterEllipsis" TextWrapping="NoWrap",当列小于长度时,我的字符串末尾会出现一个省略号的字符串.我需要的是在字符串的开头有省略号.

即如果我有字符串Hello World!,我想要...lo World!,而不是Hello W....>

有什么想法吗?

解决方案

您可以尝试使用 ValueConverter(参见 IValueConverter interface) 来更改应该自己显示在列表框中的字符串.也就是说,在Convert方法的实现中,你会测试字符串是否比可用空间长,然后将它们更改为...加上字符串的右侧.

I have a WPF ListView (GridView) and the cell template contains a TextBlock. If I add: TextTrimming="CharacterEllipsis" TextWrapping="NoWrap" on the TextBlock, an ellipsis will appear at the end of my string when the column gets smaller than the length of the string. What I need is to have the ellipsis at the beginning of the string.

I.e. if I have the string Hello World!, I would like ...lo World!, instead of Hello W....

Any ideas?

解决方案

You could try to use a ValueConverter (cf. IValueConverter interface) to change the strings that should be displayed in the list box yourself. That is, in the implementation of the Convert method, you would test if the strings are longer than the available space, and then change them to ... plus the right side of the string.

这篇关于WPF ListView 字符串开头的省略号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆