WPF TextBlock Overflow Text to the Left

Posted by shf301 on Stack Overflow See other posts from Stack Overflow or by shf301
Published on 2010-03-11T05:24:52Z Indexed on 2010/03/11 5:28 UTC
Read the original article Hit count: 221

Filed under:

As background I have a very long ID that too long to display in the given area of the TextBlock. The interesting portion of the ID is the end, that is the rightmost portion.

What I would like to do is have the TextBlock, rather than the text overflowing right and cutting off the rightmost portion, overflow left and cutoff the leftmost portion.

That is given the ID 123456 and a TextBlock with enough space to hold four characters, to get the TextBlock to display 3456 rather than 1234 as it does by default.

I could manually trim my ID for display, but given a variable spaced font that's not ideal. So is there someway to get WPF do change the overflow direction?

© Stack Overflow or respective owner

Related posts about wpf