2

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?

Nasse
  • 55
  • 4
  • Hi there, Can you give us an example of your code in this issue? – StuiterSlurf Oct 21 '18 at 07:43
  • @StuiterSlurf my code is almost same as https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/Printing/cs but do you want more specific example? – Nasse Oct 21 '18 at 07:57
  • Did you try the Document property? https://learn.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.richeditbox.document#Windows_UI_Xaml_Controls_RichEditBox_Document – Muzib Oct 21 '18 at 17:26

1 Answers1

1

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.

Nico Zhu
  • 32,367
  • 2
  • 15
  • 36