ch3rryc0ke
ch3rryc0ke

Reputation: 2803

Get text from a TextBlock with linebreaks from wrapping?

I've got a TextBlock that I'm displaying on a Canvas, that displays user entered text.

I'd like to get the content of this TextBlock, but I need to get it in such a way that I know where the linebreaks occur, for example:

enter image description here

From this displayed Textblock, how can I get the text and know where the line breaks are?

Also, this is a Windows Store App, so the full .NET framework is not available..

Upvotes: 2

Views: 207

Answers (1)

bozydar.sz
bozydar.sz

Reputation: 359

As far I know there is no way to retrieve such information from TextBlock, however you could try folowing:

  • Get TextBlock width
  • Retrieve width of your text (e.g. using FormattedText class)
  • Implement some logic which divide text in lines using text width and TextBlock width

Upvotes: 2

Related Questions