-1

I'm displaying a folder path in a WPF TextBlock but formatting characters get applied resulting in:

c:    est

instead of

c:\test

Is there a way to disable all formatting on a control so I can display as intended?

<TextBlock  Text="{Binding Name}" Style="{StaticResource StatusText}"/>
NineBerry
  • 26,306
  • 3
  • 62
  • 93
StratMan
  • 111
  • 1
  • 2
  • 7

1 Answers1

2

The problem is unrelated to WPF. You seem to use a string literal in your app like

string s = "C:\test";

This way, the tab is actually part of the string that you declare in your source file.

You need to either use a verbatim string literal

string s = @"C:\test";

or use double backslashes to escape the backslash character.

string s = "C:\\test";
NineBerry
  • 26,306
  • 3
  • 62
  • 93
  • The problem is I'm setting the string by reading and deserializing from json: `using (StreamReader r = new StreamReader("Data/backups.json")) { string json = r.ReadToEnd(); results = JsonConvert.DeserializeObject>(json); }` – StratMan Sep 25 '19 at 13:13
  • 1
    @StratMan Then the JSON is already wrong. The JSON must contain double-backslashes. Otherwise inside the JSON, \t is already a tab and not backslash followed by t – NineBerry Sep 25 '19 at 13:58