Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 75885

BindableProperty doesn't trigger PropertyChanged/Changing?

$
0
0

We have a BindableProperty set up as follows:

public static readonly BindableProperty DateProperty =
        BindableProperty.Create<DatePickerCell, DateTime?>(ctrl => ctrl.Date,
            defaultValue: default(DateTime?),
            defaultBindingMode: BindingMode.TwoWay,
            propertyChanging: (bindable, oldValue, newValue) =>
            {
                //Do something
            });

public DateTime? Date
{
   get { return (DateTime?)GetValue(DateProperty); }
   set
   {
      SetValue(DateProperty, value);
   }
}

When we set the Date property as follows:

 Date = DateTime.Now;

we see that the Date property setter is hit and the SetValue call triggers the PropertyChanging delegate. However, when we run the following code:

 Date = null;

we still hit the Date property setter and the SetValue call, but the PropertyChanging is not triggering. Why is this happening? We're trying to create a nullable DatePickerCell for usage in a TableView but without a working clear button it is kind of useless.


Viewing all articles
Browse latest Browse all 75885

Trending Articles