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

  • SEARCH
  • Home
  • 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 8384147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:20:16+00:00 2026-06-09T17:20:16+00:00

I am pulling data from a previous page which was a selected item in

  • 0

I am pulling data from a previous page which was a selected item in a listbox from a wcf service.

Ther error I am having is that the textblock is not reading the formatting in my in my data.

this is the code that brings the data in from the previous page

private void LoadPlayer()
    {
        FrameworkElement root1 = Application.Current.RootVisual as FrameworkElement;
        var currentPlayer = root1.DataContext as PlayerProfile;
        _SelectedPlayer = currentPlayer;
    }

this is the xaml

<TextBlock Height="Auto" TextWrapping="Wrap" Name="Blurb" Text="{Binding Bio}" xml:space="preserve" />

specifically I am trying to get the \r\n to work in my display as a linebreak.

  • 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-09T17:20:18+00:00Added an answer on June 9, 2026 at 5:20 pm

    See the answer here:

    Newline in string attribute

    In your case what you need to do write a Converter (something that implements IValueConverter) that turns the string data that contains the \r\n into encoded entities i.e. and . Then just use that converter on your Binding.

    public class EncodeCRLFConverter : IValueConverter
    {
      public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
      {
        string stringtoconvert = value as string;
    
        if (input != null))
        {
            // Note there are different ways to do the replacement, this is
            // just a very simplistic method.
    
            stringtoconvert = stringtoconvert.Replace( "\r", "&#x0d;" );
            stringtoconvert = stringtoconvert.Replace( "\n", "&#x0a;" );
    
            return stringtoconvert;
        }
        return null;
      }
    
      public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
      {
        throw new Exception("The method or operation is not implemented.");
      }
    }
    

    Create an instance of your converter somewhere…e.g. typically in .Resources….(in this example I’ve just used Window because I don’t know what your TextBlock is inside).

    <Window.Resources>
    <EncodeCRLFConverter x:Key="strconv"/>
    <Window.Resources>
    
    <TextBlock Height="Auto" TextWrapping="Wrap" Name="Blurb" Text="{Binding Bio, Converter={StaticResource strconv}}" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a cakePHP application that is pulling data from two different databases, which
I have an INSERT query that is pulling data from two tables and inserting
The main problem I'm having is pulling data from tables, but any other general
Background: I'm building a small application that will be run daily, pulling data from
I'm pulling data from a feed that I have no control over and I
I'm having some little issues pulling data from Twitter. Basically I am building a
My jqGrid that does a great job of pulling data from my database, but
I am thinking of putting together an app that will be pulling data from
I have a gridview which is pulling it data from a stored procedure. In
I'm pulling data from my database that is as such (raw): long's streetWe’d tree

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.