none
System.windows.controls.Richtextbox control doesn't persist carriage return (Enter "\v") symbol

    Question

  • Hi,

    In our application, we are using Richtextbox from system.windows.controls as content control to store formatted text. When we retrieve formatted text from this content control it doesn't returning us formatted text (skipping carriage return symbol).

    To retrieve text from content control we are using below code,

    rtb as RichTextBox

    Code Snippet 1 -  

    rtb.SelectAll();

    rtb.Selection.Text;

    Code Snippet 2 -

    TextRange textRange = new TextRange(

             rtb.Document.ContentStart,

             rtb.Document.ContentEnd);

    textRange.Text;

    Can you please let me know how to retrieve formatted text (with carriage return) from Rich text box control.

    Regards,

    Nitesh Gat

    Monday, January 23, 2017 9:37 AM