0

I have a RichEditBox where the user can write their own text, like below:

<RichEditBox
                            x:Name="jawabBox"
                            Grid.Row="0"
                            FontSize="21"
                            FontWeight="SemiBold"
                            HorizontalAlignment="Stretch"
                            VerticalAlignment="Stretch"
                            Background="#FFDBDBDB"
                            Foreground="Black"
                            CornerRadius="15,15,15,15" />

How to get the text that has been written by the user? Or how can the user write text into a textbox with multiple lines, other than using RichEditBox?

1
  • I've never done any UWP, but learn.microsoft.com/en-us/uwp/api/… tells me that there is a TextDocument property, which is of type RichEditTextDocument, which has a GetText method. That looks promising.
    – Flydog57
    Nov 23, 2021 at 5:07

1 Answer 1

0

As @Flydog57 mentioned, you could get the text via the ITextDocument.GetText() Method. It requires a TextGetOptions Enum as parameter and a string as output value.

You could use it like this:

 string value = string.Empty;
        jawabBox.Document.GetText(Windows.UI.Text.TextGetOptions.AdjustCrlf, out value);
2
  • I want the text taken from RichEditBox to be a string or TextBlock
    – Rose
    Nov 23, 2021 at 8:52
  • @Rose Yes, the value is a string. You could try the code in your own project. Nov 23, 2021 at 9:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.