c# - Get TextBlock lines as separate strings WPF -
is there way textblock lines separate strings after text wrapping? example, if have textblock defined this:
textblock mytextblock = new textblock(); mytextblock.textwrapping = textwrapping.wrap; mytextblock.text = verylongstring;
is possible separate string each row displayed in textblock, created textwrapping.wrap?
textblock has property called inline
, use , access strings 1 one,
stringbuilder s = new stringbuilder(); foreach (var line in txtsample.inlines) { if (line linebreak) s.appendline(); else if (line run) s.append(((run)line).text); } var text = s.tostring(); }