zirkelc
zirkelc

Reputation: 1713

Windows Phone - First line of TextBox

I've founded the following code to take the first line from a string:

string firstline = test.Substring(0, test.IndexOf(Environment.NewLine));

This does not work because the XAML TextBox uses a \r to represent a linebreak, but Environment.NewLine is \r\n.

Is there a defined constant string for NewLine in WindowsPhone/XAML?

Upvotes: 2

Views: 226

Answers (2)

lhan
lhan

Reputation: 4635

Try splitting on "\r", I found an example in the answer here.

Hope this helps!

Upvotes: 2

Christian Amado
Christian Amado

Reputation: 943

Your code is fine. Did you set MultiLine property to true?

Environment.NewLine defines
A string containing "\r\n" for non-Unix platforms, or a string containing "\n" for Unix platforms.

Hope it helps.

Upvotes: 1

Related Questions