I have a TextBox defined as below:
<TextBox x:Name="TextBoxName"
TextWrapping="Wrap"
AcceptsReturn="True"
BorderThickness="0"
PlaceholderText="{Binding PlaceHolderText}"
Text="{Binding TestValue, Mode=TwoWay}" />
When I type test1
, then type Enter
key, and then type test2
in this multiple lines text box, I check the value of TestValue
and I see test1\rtest2
. I am confused, why the return is displayed as \r
only here. In windows isn't it be \r\n
?
If I want to write test1\rtest2
into xml, can I replace \r
with \n
which is unix style? I tried to use this but it doesn't work.
XmlWriterSettings xws = new XmlWriterSettings();
xws.NewLineChars = "\n";
xws.NewLineHandling = NewLineHandling.Replace;
From this post, it mentions this line breaks(only \r) are by design. So if you want to replace "\r" with "\n" in xml, as a workaround, you could first replace the "\r" in textbox's Text and then write it into xml.
Or use Environment.NewLine method to get the newline string defined for this environment.