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

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

问题描述

我有一个WPF 的ListView GridView控件)和电池模板包含一个的TextBlock 。如果我补充一下: TextTrimming =CharacterEllipsisTextWrapping =NoWrap的的TextBlock ,省略号将出现在我的字符串的结尾,当列获得比字符串的长度。我需要的是有省略号在字符串的开头。

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.

即。如果我有字符串的Hello World!,我想 ...罗世界!,而不是你好W¯¯...

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

任何想法?

推荐答案

您可以尝试使用ValueConverter(见的 的IValueConverter 的介面)更改应显示在列表框中自己的字符串。
即,在转换方法的实施,你将测试如果字符串大于可用空间更长,然后将它们改变到...加上字符串的右侧。

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天全站免登陆