Bug 22154 - Problem adding carriage return to editor control
Summary: Problem adding carriage return to editor control
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.2.2
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2014-08-17 20:36 UTC by mgwalm
Modified: 2016-03-16 12:19 UTC (History)
5 users (show)

Is this bug a regression?: ---
Last known good build:

sample code (522 bytes, application/xaml+xml)
2014-08-20 19:29 UTC, mgwalm
code sample (299 bytes, text/plain)
2014-08-20 19:30 UTC, mgwalm

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description mgwalm 2014-08-17 20:36:31 UTC
if I have one line of text in an editor control and go  to the end of it and tap return on the keypad, it junps to the beginning of the line and doesn't add a new line.

it does this always on the last or only line in the editor control.
Comment 1 Seth Rosetter 2014-08-18 14:08:54 UTC
Can you provide us with a code example? Also, which platform(s) are you experiencing this behavior on?
Comment 2 mgwalm 2014-08-18 19:15:23 UTC
win phone, I haven't tried any other platforms. I can later today.

its the simplest bit of code:

    <StackLayout Orientation="Vertical" Padding="5" Spacing="0">
      <Label TextColor="{x:Static helpers:Colors.LabelTextColor}" Text="{Binding Description}" HorizontalOptions="Center" />

      <Grid RowSpacing="0">
          <ColumnDefinition Width="100" />
          <ColumnDefinition Width="*" />
          <RowDefinition Height="auto" />
          <RowDefinition Height="auto" />
          <RowDefinition Height="auto" />
          <RowDefinition Height="*" />

        <Label TextColor="{x:Static helpers:Colors.LabelTextColor}" Text="Quoted:" VerticalOptions="Center"/>
        <Entry BackgroundColor="{x:Static helpers:Colors.TextBackgroundColor}" Text="{Binding CurrentLine.QuantityQuoted, Mode=TwoWay}" Grid.Column="1" StyleId="Special"/>

        <Label TextColor="{x:Static helpers:Colors.LabelTextColor}" Text="Used:" VerticalOptions="Center" Grid.Row="1"/>
        <Entry BackgroundColor="{x:Static helpers:Colors.TextBackgroundColor}" Text="{Binding CurrentLine.QuantityInstalled, Mode=TwoWay}" Grid.Row="1" Grid.Column="1" />

        <Label TextColor="{x:Static helpers:Colors.LabelTextColor}" Text="Comment:" VerticalOptions="Center" Grid.Row="2" Grid.ColumnSpan="2"/>
        <Editor Text="{Binding CurrentLine.Comment, Mode=TwoWay}" Grid.Row="3" Grid.ColumnSpan="2" />
Comment 3 mgwalm 2014-08-18 22:11:59 UTC
Ive discovered where the problem is. IT is happening because of the binding. if you remove it, it works as expected.

<Editor Text="text" Grid.Row="3" Grid.ColumnSpan="2" />
Comment 5 mgwalm 2014-08-19 22:05:34 UTC
i think it is themvvm package im using, it is trimming the value to remove any trailing space chars, which is removing the return at the end as well.
Comment 6 mgwalm 2014-08-19 22:30:56 UTC
ive just run a pure wp8 version of the mvvm package (not a pcl version). it's the exact same code as ive compiled it my self in a wp8 and a pcl project.

the pure wp8 version works as expected, ie even though the code is trimming the value, what is displayed on the phone is correct, ie, it contains the return.

there appears to be a difference in how the binding is working.
Comment 7 Seth Rosetter 2014-08-20 15:08:33 UTC
Is this resolved for you? If it is not, please verify it is an issue with Xamarin.Forms or an issue with using the  external library. Which mvvm package are you using? We are interested in compatibility with external libraries, however, when it comes to that area, we can't make any promises.
Comment 8 mgwalm 2014-08-20 19:27:54 UTC
I have a workaround. however I think the problem is really in the binding. ive been using the mvvm package for over five years on wpf, win rt and win phone without any issues.

Ive downloaded the xaml samples from github and made the attached changes to the homepage. (there is no way to attach anything to this comment)

if you run it you'll notice that the setter for text is called twice when I have the following code in place:
    public string Text
        return _text;
        Debug.WriteLine("Set Text value={0}", value ?? "");
        _text = value == null ? null : value.TrimEnd(); //new[]{' '});
it is called only once when the trim is removed:
        _text = value;

So I think the problem is with the binding code.

However I have a work around so please close the issue.
Comment 9 mgwalm 2014-08-20 19:29:49 UTC
Created attachment 7747 [details]
sample code
Comment 10 mgwalm 2014-08-20 19:30:26 UTC
Created attachment 7748 [details]
code sample
Comment 11 Jason Smith [MSFT] 2016-03-16 12:19:44 UTC
Thank you for taking the time to submit this report. After reviewing the description of this bug, we no longer believe it affects the current version of Xamarin.Forms. If you are still experiencing the issue after updating your packages, please reopen this report with an attached reproduction.
For your convenience, we have created some reproduction best practices viewable here: https://gist.github.com/jassmith/92405c300e54a01dcc6d

Warm regards,
Xamarin Forms Team