Reputation: 3768
How can I get a linebreak in TextBox in WP7? I'm developing social-based app(like facebook) and if I set AcceptReturn=true, it gives me a visual(ui) linebreak, but when I send this text to the server I can see that there is no linebreak. Please help me with this problem. I've tried
void whatsend_KeyDown(object sender, System.Windows.Input.KeyEventArgs e) {
if (e.Key == Key.Enter) {
whatsend.Text +="\r";//or /n,
}
}
but with no success.
Upvotes: 6
Views: 14550
Reputation: 83
just add below scope to xaml code:
AcceptsReturn="True" TextWrapping="Wrap"
something like this:
<TextBox x:Name="InputText" Height="200" VerticalAlignment="Top" Width="456" TextAlignment="Center" TextWrapping="Wrap" AcceptsReturn="True"/>
Upvotes: 2
Reputation: 124790
Windows uses \r\n
for line breaks, not \r
, but that's irrelevant; use Environment.NewLine
instead.
Also, per the docs:
true if the ENTER key creates a new line of text in a multiline version of the control; false if the ENTER key activates the default button for the form. The default is false.
Did you set MultiLine
to true
?
EDIT: Ahhh, WP7... here is an article I found which attempts to create a multi-line textbox in WP7.
Upvotes: 6
Reputation: 3290
I'm not familiar with WP7 but Windows in general uses "\r\n
" (i.e. both chars one after the other) to signify a line break.
If you append both to your text, does it solve your problem?
Having said that, I'm surprised that typed line breaks are being removed from the textbox. When you say the text isn't viewable on the server, what do you mean? Is it that the text isn't sent to and / or recorded on the server or that your method of display on the server isn't showing it?
Upvotes: 0