Note that there are some explanatory texts on larger screens.

plurals
  1. POObservableCollection dependency property does not update when item in collection is deleted
    text
    copied!<p>I have a attached property of type ObservableCollection on a control. If I add or remove items from the collection, the ui does not update. However if I replace the collection within with a new one the ViewModel the ui does update.</p> <p>Can someone give me an example of what I need to do within the Dependency object so that it can handle changes within the collection?</p> <p>Part of the dependency object is listed below:</p> <pre><code>public class RadCalendarBehavior : DependencyObject { private static void OnSpecialDaysChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var calendar = d as RadCalendar; if (e.NewValue != null) { calendar.DayTemplateSelector = new SpecialDaySelector((ObservableCollection&lt;DateTime&gt;)e.NewValue, GetSpecialDayTemplate(d)); } } public static ObservableCollection&lt;DateTime&gt; GetSpecialDays(DependencyObject obj) { return (ObservableCollection&lt;DateTime&gt;)obj.GetValue(SpecialDaysProperty); } public static void SetSpecialDays(DependencyObject obj, ObservableCollection&lt;DateTime&gt; value) { obj.SetValue(SpecialDaysProperty, value); } public static readonly DependencyProperty SpecialDaysProperty = DependencyProperty.RegisterAttached("SpecialDays", typeof(ObservableCollection&lt;DateTime&gt;), typeof(RadCalendarBehavior), new UIPropertyMetadata(null, OnSpecialDaysChanged)); } } </code></pre> <p>I understand that I need to register that the collection has changed, but I am unsure how to do this within the dependency property</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload