BindingList not firing PropertyChangedCallBack on DependecyProperty RRS feed

  • Question

  • I have the followin property in my VM.


    private BindingList<DateTime> diasAgendados = new BindingList<DateTime>();

    public BindingList<DateTime> DiasAgendados


                    get { return diasAgendados; }

                    set { diasAgendados = value; RaisePropertyChanged("DiasAgendados"); }


    And the following method for adding a new item for the BindingList in the VM

    private void AgregarFecha(DateTime agendar_fecha)  
       if (!DiasAgendados.Contains(agendar_fecha))    

    In my view i have the following dependency property


        public static readonly DependencyProperty DiasAgendadosPropiedad = DependencyProperty.Register("DiasAgendados", typeof(BindingList<DateTime>),                typeof(CalendarioView), new FrameworkPropertyMetadata(new PropertyChangedCallback(DiasAgendadosProperty_Changed)));
                    private static void DiasAgendadosProperty_Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
      var obj = (CalendarioView)sender;
      if (e.NewValue != null && obj.SelectedMes > 0 && obj.SelectedAnio > 0)
    public BindingList<DateTime> DiasAgendados
     get { return (BindingList<DateTime>)GetValue(DiasAgendadosPropiedad); }
    set { SetValue(DiasAgendadosPropiedad, value); }

    Now if i manually set a new bindinglist already populated by default to the property in the VM the propertyChangedCallback will trigger.
    But if try to add new items to the bindinglist in the VM it does not trigger.
    I have already tried the following fix:

        if (!DiasAgendados.Contains(agendar_fecha))

    Why isn't the propertyChangedCallback on the dependency property firing?
    Wednesday, September 2, 2015 12:34 AM


  • Because the property hasn't changed, it's still the same collection.

    The Propertychanged callback here

      public static readonly DependencyProperty DiasAgendadosPropiedad = DependencyProperty.Register("DiasAgendados", typeof(BindingList<DateTime>),                typeof(CalendarioView), new FrameworkPropertyMetadata(new PropertyChangedCallback(DiasAgendadosProperty_Changed)));
    Is only going to fire when you set the bindinlist to a new bindinglist or null or some such - the entire bindinglist.

    It's listchanged that you'd have to check in order to know when an item is added or removed.


    Not many xaml devs use bindinglist.

    Most devs use observablecollection and collectionchanged, by the way.

    • Marked as answer by venom_aa Wednesday, September 2, 2015 3:28 PM
    Wednesday, September 2, 2015 8:54 AM