Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TwoWay binding calls setter on creation #4721

Closed
maxkatz6 opened this issue Sep 23, 2020 · 2 comments
Closed

TwoWay binding calls setter on creation #4721

maxkatz6 opened this issue Sep 23, 2020 · 2 comments

Comments

@maxkatz6
Copy link
Member

maxkatz6 commented Sep 23, 2020

Failing tests:

[Fact]
public void TwoWay_Binding_Should_Not_Call_Setter_On_Creation()
{
    var target = new Class1();
    var source = new TestTwoWayBindingViewModel() { Value = 1 };

    target.Bind(Class1.DoubleValueProperty, new Binding(nameof(source.Value), BindingMode.TwoWay) { Source = source });

    Assert.False(source.SetterCalled); // SetterCalled is true
}

[Fact]
public void TwoWay_Binding_Should_Not_Call_Setter_On_Creation_Indexer()
{
    var target = new Class1();
    var source = new TestTwoWayBindingViewModel() { [0] = 1 };

    target.Bind(Class1.DoubleValueProperty, new Binding("[0]", BindingMode.TwoWay) { Source = source });

    Assert.False(source.SetterCalled); // SetterCalled is true
}

Both "Class1" and "TestTwoWayBindingViewModel" exist in AvaloniaObjectTests_Binding test class.

@maxkatz6 maxkatz6 changed the title TwoWay binding calls setter on getting value TwoWay binding calls setter on creation Sep 23, 2020
@maxkatz6
Copy link
Member Author

It doesn't call setter if property has default value.
Because of that existing TwoWay_Binding_Should_Not_Call_Setter_On_Creation and TwoWay_Binding_Should_Not_Call_Setter_On_Creation_Indexer tests passing.

@maxkatz6
Copy link
Member Author

Can't be reproduced anymore. Added tests in related PR #7786

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant