Aaron Thomas
Aaron Thomas

Reputation: 5281

WPF textbox insert control characters such as tab, newline, or return

How can I set up a WPF TextBox, so that it displays control characters that are passed to it through binding?

For example, if I have the test string "Start\\tafter tab\\rafter return", and I bind the Text property of the TextBox to this, how can I get it to display with the tabs and returns?

I should note the TextBox has AcceptsReturn="True" and AcceptsTab="True".

Upvotes: 0

Views: 2851

Answers (1)

Valentin
Valentin

Reputation: 5488

Use single \t instead of \\t.

TextBox.Text = "Start\tafter tab\rafter return";

Double \\t doesn't transform to tab, it transforms to \t.

Upvotes: 2

Related Questions