BindingContextChanged OldValue NewValue


When BindingContext changed, allow intercept old and new value.

API Changes

public class BindablePropertyChangedEventArgs
    public object NewValue {get; Internal sets; }
    public object OldValue {get; Internal sets; }
    public BindableProperty Property {get; Internal sets; }

public event EventHandler <BindablePropertyChangedEventArgs> BindingContextChanged;

and use like this:

bindableObject.BindingContextChanged+= (s,e)=>
             var oldValue = e.OldValue as  INotifyPropertyChanged;
             var newValue = e.NewValue as  INotifyPropertyChanged;            
             if ( oldValue != null)
                   oldValue.PropertyChanged -= onPropertyChangedHandler; 
             if ( newValue != null)
                   newValue.PropertyChanged += onPropertyChangedHandler; 

0 votes

Open · Last Updated


  • rogiheerogihee NLMember ✭✭✭

    Great addition! I really needed this sometimes too.

  • wesharpwesharp ITMember

    On my forked of Xamarin.Forms , i have create two branch with different approc:

    • In the first i have implemented BindablePropertyChangedEventArgs and BindingPropertyChangedEventHandler
    • In the second i have using the existing delegate BindingPropertyChangedDelegate.

    What is the best approach?

  • wesharpwesharp ITMember

    Any news?

  • StephaneDelcroixStephaneDelcroix USInsider, Beta ✭✭✭✭

    BindingContext is a bindable property, so you can listen to both PropertyChanging and PropertyChanged events. Do the cleanup (remove event handler, e.g.) in PropertyChanging and build up in PropertyChanged

Sign In or Register to comment.