Double simultaneously changing of the property fires only one propertyChanged

JTOneJTOne ✭✭USMember ✭✭

Double simultaneously changing of the property fires only one BindableProperty.PropertyChanged event and second is ignored.

Examples

MyProperty = "test1";
MyProperty = "test2";
//The BindableProperty.PropertyChanged will be called once.

MyProperty = "test1";
await Task.Delay(75);
MyProperty = "test2";
//The BindableProperty.PropertyChanged will be called twice.

Do I have the ability to config the delay to make the first code works the same as the second?

Answers

  • JohnHardmanJohnHardman mod GBUniversity mod

    @JTOne

    Assuming that MyProperty is a property in a View Model class, post the code of your View Model class and any base class that it inherits from.

  • JTOneJTOne ✭✭ USMember ✭✭
    edited February 20

    Double simultaneously changing of the view model property fires only one BindableProperty.PropertyChanged event and second is ignored.

    Examples

    VM.MyProperty = new Point[1];
    VM.MyProperty = new Point[2];
    //The BindableProperty.PropertyChanged will be called once.
    

    -

    VM.MyProperty = new Point[1];
    await Task.Delay(75);
    VM.MyProperty = new Point[2];
    //The BindableProperty.PropertyChanged will be called twice.
    

    --XAML

    <cc:MyControl UpdatePoints="{Binding MyProperty}">
    </cc:MyControl>
    

    -- My custom control that bound to the MyProperty

    public static BindableProperty UpdatePointsProperty = BindableProperty.Create("UpdatePoints", typeof(Point[]), typeof(Scene), null, BindingMode.OneWay, propertyChanged: UpdatePointsChanged);
    public Defenition UpdatePoints
    {
        get { return (Defenition)GetValue(UpdatePointsProperty); }
        set { SetValue(UpdatePointsProperty, value); }
    }
    private static void UpdatePointsChanged(BindableObject bindable, object oldValue, object newValue)
    {
    //only once, but I need it twice 
    }
    

    Do I have the ability to config the delay to make the first code works the same as the second?

  • JohnHardmanJohnHardman mod GBUniversity mod

    @JohnHardman said:
    @JTOne

    Assuming that MyProperty is a property in a View Model class, post the code of your View Model class and any base class that it inherits from.

    @JTOne said:
    Do I have the ability to config the delay to make the first code works the same as the second?

    I suspect there is something amiss in your code, but not enough code is currently shown to identify the problem.

Sign In or Register to comment.