WPF - 有类似 PathCompactPath 的东西吗?
我想像 Windows 窗体中的 PathCompactPath 那样压缩文件路径,因此当您伸展父控件时,更多的文件路径变得可见,反之亦然。
由于 PathCompactPath 使用字符大小,WPF 中是否有类似的使用像素大小/dpi 的内容?或者某种转换器?
I would like to compact filepaths the same way that PathCompactPath does in Windows Forms, so when you stretch out the parent control, more of the filepath becomes visible and vice versa.
Since PathCompactPath uses character sizes, is there any similar in WPF that uses pixel sizes/dpi? Or a converter of some kind?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,恕我直言,Windows 窗体中不存在 PathCompactPath。您必须在那里使用 PInvoke。
不幸的是,WPF 中也没有此功能。最接近您需要的是 TextBlock.TextTrimming< /a>.我也不知道有任何第三方控件可以做到这一点。不过,您可以自己推出。使用 FormattedText (
.Width< /code> 和
.Height
),您可以在渲染之前测量字符串。您还可以使用它来实际渲染文本。First of all, IMHO PathCompactPath does not exist in Windows Forms. You would have to use PInvoke there.
Unfortunately this functionality is also not in WPF. The closest to what you need is TextBlock.TextTrimming. I also do not know of any 3rd party control that can do this. You yould however roll your own. Using FormattedText (
.Width
and.Height
) you can measure your string before you render it. You can also use it to actually render text.