WPF - 有类似 PathCompactPath 的东西吗?

发布于 2024-10-01 17:22:35 字数 146 浏览 0 评论 0原文

我想像 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时光无声 2024-10-08 17:22:35

首先,恕我直言,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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文