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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:49:29+00:00 2026-06-15T20:49:29+00:00

I have a WPF MVVM application which stores some text in a database (nvarchar).

  • 0

I have a WPF MVVM application which stores some text in a database (nvarchar). This text includes \n to indicate a new line. When I view the column in SQL Management Studio, it displays \n as expected but when the data is being retrieved using Entity Framework, it brings back \\n which causes the newline not to be displayed when I’m binding the property to my textblock.

How can I stop this behaviour?

Some additional information:
The text comes back from the DB and gets assigned to a property on the viewmodel which is then bound to the textblock. If I hardcode the property to be something like “Time\nStamp”, it works perfectly with the textblock displaying the data on 2 separate lines. The problem only seems to lie in Entity or the DB. I’m using SQL server 2012 btw.

  • 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-15T20:49:30+00:00Added an answer on June 15, 2026 at 8:49 pm

    From C# Obeying the NewLine Character in a String Pulled from SQL server, when you retrieve a string from SQL, the value stored in the database is stored as a literal. When the \n is retrieved, it is read into the string value as a literal, and not a New Line escape character.

     str.Replace("\\n", Environment.NewLine); // Changes the escaped new line character to a NewLine character, environmental dependent.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In a WPF/MVVM application I have a custom control on a particular view. This
I have an application which I am developing using WPF\Prism\MVVM. All is going well
I have a WPf Toolkit-datagrid..in my application which follows MVVM pattern. How I can
In a WPF application following MVVM pattern I have a Customer class which has
I have a WPF application that mostly follows MVVM, which I am trying to
Let's say I have a WPF application which makes use of the MVVM pattern.
I have a WPF application developed against the MVVM framework in which the ViewModel
I have large WPF-MVVM application in which I have 1 subscribe and 2 publish
I have a WPF application which is built on the MVVM design pattern. I
I have a WPF application designed using MVVM. I have a view which will

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.