Johan Alkstål
Johan Alkstål

Reputation: 5347

WPF - Is there something similar to PathCompactPath?

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?

Upvotes: 3

Views: 429

Answers (1)

bitbonk
bitbonk

Reputation: 49619

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.

Upvotes: 2

Related Questions