Nasse
Nasse

Reputation: 55

UWP how to get text from RichEditBox to RichTextBlock

If i have RichEditBox what contains some text how could i get all of that text and move it to RichTextBlock?

Example text below:

RichEditBox

Closest what i have got looks like following

enter image description here

I have used Microsoft own example in this project. I would like also keep text formatting while getting text from the RichEditBox. Is this kind of thing even possible to do?

Upvotes: 2

Views: 1247

Answers (1)

Nico Zhu
Nico Zhu

Reputation: 32775

If i have RichEditBox what contains some text how could i get all of that text and move it to RichTextBlock?

You could get Text from RichEditBox with ITextDocument.GetText method. And the output string could contain rft format depend on which TextGetOption you used.

But, the rtf string could not be loaded with RichTextBlock, it does not support RTF. it only support the formatting with xaml Block elements.

Currently there is a workaround that you could convert your rft string to html and display the content with UWP WebView. For more you could refer this case reply in msdn.

Upvotes: 1

Related Questions