0

So, let's say I have a really long text:

One Two Three Four Five Six Seven Eight Nine Ten

And I have this textblock:

---------------
|One Two Three|
|Four Five Six|
|Seven Eight  |
|Nine Ten     |
---------------

Now, what I need to do is make this box smaller, and let the remaining text to overflow on a different textblock:

---------------
|One Two Three|
|Four Five Six|
---------------
---------------
|Seven Eight  |
|Nine Ten     |
---------------

Text must not be trimmed with ellipses, nor cut-off. THe first textblock needs to be filled as much as possible.

I could not find a way to do this in xaml/code-behind. The length of the text could be unknown, but the size of the textblocks are fixed. Textblocks need to wrapped, with no trimming/cut-off words. No scroll bars, no tool tips. Fontsize/fontweight/font family could also differ.

Any ideas?

Flip Booth
  • 271
  • 3
  • 11
  • Can I ask where this new text block comes from? it looks like it takes up the same amount of space as the old one if not more, is a scroll bar not enough? – Sayse Sep 18 '14 at 14:20
  • Actually, I just need to spread the text across multiple textblocks, with the first textblocks being filled to max without truncation. This is the requirement. Scroll bar is not allowed. The other textblocks could be on a different window. I just need to know how to spread them. – Flip Booth Sep 18 '14 at 14:28
  • use some form of measuring text render size such as [this](http://stackoverflow.com/questions/9264398/how-to-calculate-wpf-textblock-width-for-its-known-font-size-and-characters) to measure how large the text will be. Cut it up into substrings of a certain size that fits into one of your textblocks and then take those substrings and give each to its own textblock. – mhoward Sep 18 '14 at 14:32
  • Also if finding out how much text will fit in your textblocks becomes a problem (since its always the same size it shouldnt be I would imagine.) You can use this more [complicated solution](http://stackoverflow.com/questions/4319031/get-displayed-text-from-textblock) to always find the right size. Edit someone has already shown you this based off of your last question it looks like, why did you not run with this already? – mhoward Sep 18 '14 at 14:35
  • @mhoward that will not work with textwrapping – Flip Booth Sep 18 '14 at 15:28

0 Answers0