Bug 22433 - Binding doing funny thing
Summary: Binding doing funny thing
Status: RESOLVED NOT_REPRODUCIBLE
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.2.2
Hardware: PC Windows
: Normal minor
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-08-27 19:16 UTC by mgwalm
Modified: 2016-06-13 16:00 UTC (History)
5 users (show)

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


Attachments
hellopage.xaml (3.01 KB, application/xaml+xml)
2014-08-27 19:21 UTC, mgwalm
Details
homepage.xaml.cs (3.85 KB, text/plain)
2014-08-27 19:22 UTC, mgwalm
Details


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:
Status:
RESOLVED NOT_REPRODUCIBLE

Description mgwalm 2014-08-27 19:16:31 UTC
I have an issue with binding. Some code follows:
some properties i'm binding to:
    private double _value;

    public double Value
    {
      get
      {
        return _value;
      }
      set
      {
        Debug.WriteLine("Set Value value={0}", value);
        _value = value;
        OnPropertyChanged("Value");
      }
    }
	
    private string _text;

    public string Text
    {
      get
      {
        return _text;
      }
      set
      {
        Debug.WriteLine("Set Text value={0}", value ?? "");
        _text = value;
        OnPropertyChanged("Text");
      }
    }

the constructor of my page
    public HomePage()
    {
      InitializeComponent();

      BindingContext = this;
      Text = "one line";
      Value = 1.1D;
    }
 the xaml in my page:
    <StackLayout Orientation="Vertical" Padding="0" Spacing="0">
      <Label TextColor="Red" Text="Binding Description" HorizontalOptions="Center" />

      <Grid RowSpacing="0" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="100" />
          <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <Grid.RowDefinitions>
          <RowDefinition Height="auto" />
          <RowDefinition Height="auto" />
          <RowDefinition Height="Auto" />
          <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <Label TextColor="Red" Text="Quoted:" VerticalOptions="Center"/>
        <Entry Text="{Binding Value}" Grid.Column="1" StyleId="Special"
               VerticalOptions="StartAndExpand"
               BackgroundColor="Gray" />

        <Label TextColor="Red" Text="Used:" VerticalOptions="Center" Grid.Row="1"/>
        <Entry Text="{Binding Text, Mode=OneWay}" Grid.Row="1" Grid.Column="1"
               VerticalOptions="Start"
               BackgroundColor="Gray" />

        <Label TextColor="Red" Text="Comment:" VerticalOptions="Center" Grid.Row="2" Grid.ColumnSpan="2"/>
        <Editor Text="{Binding Text, Mode=TwoWay}" Grid.Row="3" Grid.ColumnSpan="2"
                VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand"
                BackgroundColor="Gray"
                Keyboard="Text"/>
      </Grid>
    </StackLayout>


I get this (the debug output) when the constructor executes:

Set Value value=0
Set Text value=one line
Set Value value=1.1
Set Value value=1.1
Set Text value=one line

you'll notice the value is set twice when i'm binding to a double, but set only once when binding to a string.
Comment 1 mgwalm 2014-08-27 19:21:35 UTC
Created attachment 7843 [details]
hellopage.xaml
Comment 2 mgwalm 2014-08-27 19:22:16 UTC
Created attachment 7844 [details]
homepage.xaml.cs
Comment 3 mgwalm 2014-08-27 19:23:16 UTC
I forgot to say just use the xaml samples downloaded from github and replace the homepage with the attached files.
Comment 4 Arpit Jha 2014-08-28 08:22:00 UTC
I have checked this issue and able to reproduce it.

I have tried following steps to reproduce it.
1.Download XamlSamples from Github.
2.Modify code as above mentioned.
3.Run the application.


I observed that value set twice when  binding to double or Text.

Screencast: http://screencast.com/t/UM5v82iK2

Environment Info: 
Microsoft Visual Studio Professional 2013
Version 12.0.30723.00 Update 3
XVS 3.3.47.0
Comment 5 Rui Marinho 2016-06-13 16:00:15 UTC
Thank you for taking the time to submit this report. After reviewing the description of this bug, we believe it no longer 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