Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8715655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:53:59+00:00 2026-06-13T05:53:59+00:00

I spent my day searching on the internet a solution to my problem without

  • 0

I spent my day searching on the internet a solution to my problem without success … That seems simple enough in theory.

I have a RichTextBox in XAML.
I have in my database a field named “content” type “LongText”

I just want my database saves the contents of the RichTextBox with simple style (bold, italic, underline) and that I can call my database, fill my RichTextBox content stored in my database while keeping the style of the text.

After that, I’ll have to show these data as a blog but … must already successfully save and load data.

XAML :

<RichTextBox x:Name="nameTextEditor" TabIndex="2" Grid.Row="2" SpellCheck.IsEnabled="True">

C#

FlowDocument doc = new FlowDocument();
        StringReader sr = new StringReader(monArticle.Content);
        XmlReader xmlReader = XmlReader.Create(sr);
        Section sec = XamlReader.Parse(monArticle.Content) as Section;
        while (sec.Blocks.Count > 0)
        {
            var block = sec.Blocks.FirstBlock;
            sec.Blocks.Remove(block);
            doc.Blocks.Add(block);
        }
        nameTextEditor.Document = doc;

Don’t work with error :
“Exception XamlParseException”
“Données non valides au niveau racine. Ligne 1, position 1.”

This is not the only code I tried but I test without understanding a word … Why it is not so easy to “take the contents of the RichTextBox” and “send in my database”?!

Thanks for all help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T05:54:00+00:00Added an answer on June 13, 2026 at 5:54 am
        var doc = rtb.Document;
        var range = new TextRange(doc.ContentStart, doc.ContentEnd);
        var ms = new MemoryStream();
        range.Save(ms, DataFormats.Rtf);
        ms.Seek(0, SeekOrigin.Begin);
    
        var rtfString=new StreamReader(ms).ReadToEnd();
    

    Now send rtfString to the database.
    To display it back in the richtext box:

    var doc = rtb.Document;
    var range = new TextRange(doc.ContentStart, doc.ContentEnd);
    var ms = new MemoryStream();
    var sw = new StreamWriter(ms);
    sw.Write(rtfString);
    sw.Flush();
    ms.Seek(0, SeekOrigin.Begin);
    range.Load(ms, DataFormats.Rtf);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have spent about half a day searching for an answer to this question
I have spend over a day searching a solution about this. I ran the
I have spent the last day searching documentation, reviewing forum posts, and googling to
I've spent the day trying to figure out a strange problem. I have a
I've spent a whole day searching for a solution on how to get wsgen
I need help in a php script. Have spent half a day searching high
I have been searching the internet for days trying to solve this problem. I
Okay, so i have spent all day searching the web for why this is
I have spent the last day searching and reading various sites and articles to
I've spent a whole day on this already without figuring it out. I'm hoping

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.