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 6873669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:05:52+00:00 2026-05-27T04:05:52+00:00

What is c# code equivalent of following XAML, where I have a RichTextBox and

  • 0

What is c# code equivalent of following XAML, where I have a RichTextBox and I have selected Paragraph, and I want to enable/disable white space on this paragraph. In XAML I know how to enable, but I need to do this in code.

<Paragraph xml:space=\"preserve\">     Tabbed Code</Paragraph>

There is an equivalent I have found and its here,

void EnableWhiteSpace(Paragraph p, bool enable = true){
   if(enable){
         System.Windows.Markup.XmlAttributeProperties
              .SetXmlSpace(this.Document, "preserve");
   }
   else{
         System.Windows.Markup.XmlAttributeProperties
              .SetXmlSpace(this.Document, "default");
   }
}

This is still not working !!! I am not getting tabs !!…

Here is my problem, I have a RichTextBox which is used to edit code and which does syntax highlighting. Everything is fine except when I call following I see no tabs in my code.

 TextRange tr = new TextRange(
                         myRichTextBox.Document.ContentStart,
                         myRichTextBox.Document.ContentEnd);
 string text = tr.Text;

The text that I receive contains no tabs, so I thought enabling whitespace on every paragraph before doing text range might give me tabs.

UPDATE

I tried navigating every inlines (run) in the paragraph, none contains tab, I am just loosing all the tabs 🙁

  • 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-05-27T04:05:53+00:00Added an answer on May 27, 2026 at 4:05 am

    RichTextBox is buggy, it will just ignore all tabs, however its problem of WPF itself and cant be fixed without doing complex workarounds.

    Alernative is to write your own FlowDocument to text converter, however this is very complex as nodes do not directly give any line or tag information.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code in Ruby. I want to convert this code into
I want to write the following C# code equivalent in JavaScript/jQuery (x == 0
I have this vb.net code ( but I think meaning code is equivalent for
I want to do the equivalent of this R code: m2 <- cbind(1,2) colnames(m2)
I would like to do the equivalent of the following xaml in code, but
I want to know the code equivalent of the part that is inside the
I'd like to convert the following XAML sample code into its C# equivalent: <Grid>
Hi I want to know the equivalent code in struts. <-select-> <-option value=a-> a
I am trying to write equivalent linq code for following query. SELECT A.* FROM
What could be a LINQ equivalent to the following code? string[] values = {

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.