How to deal with the new line character in the Silverlight TextBox

Posted by Ian Oakes on Stack Overflow See other posts from Stack Overflow or by Ian Oakes
Published on 2010-06-11T12:13:02Z Indexed on 2010/06/11 12:52 UTC
Read the original article Hit count: 226

Filed under:
|

When using a multi-line TextBox (AcceptsReturn="True") in Silverlight, line feeds are recorded as \r rather than \r\n. This is causing problems when the data is persisted and later exported to another format to be read by a Windows application.

I was thinking of using a regular expression to replace any single \r characters with a \r\n, but I suck at regex's and couldn't get it to work.

Because there may be a mixture of line endings just blindy replacing all \r with \r\n doesn't cut it.

So two questions really...

If regex is the way to go what's the correct pattern?

Is there a way to get Silverlight to respect it's own Environment.NewLine character in TextBox's and have it insert \r\n rather just a single \r?

© Stack Overflow or respective owner

Related posts about regex

Related posts about Silverlight