Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The ContentList's Set method will not get called when you change a value inside the collection, instead you should be looking out for the <a href="http://msdn.microsoft.com/en-us/library/ms653375.aspx" rel="nofollow noreferrer">CollectionChanged</a> event firing.</p> <pre><code>public class CollectionViewModel : ViewModelBase { public ObservableCollection&lt;EntityViewModel&gt; ContentList { get { return _contentList; } } public CollectionViewModel() { _contentList = new ObservableCollection&lt;EntityViewModel&gt;(); _contentList.CollectionChanged += ContentCollectionChanged; } public void ContentCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { //This will get called when the collection is changed } } </code></pre> <hr> <p>Okay, that's twice today I've been bitten by the MSDN documentation being wrong. In the link I gave you it says:</p> <blockquote> <p>Occurs when an item is added, removed, changed, moved, or the entire list is refreshed.</p> </blockquote> <p>But it actually <em>doesn't</em> fire when an item is changed. I guess you'll need a more bruteforce method then:</p> <pre><code>public class CollectionViewModel : ViewModelBase { public ObservableCollection&lt;EntityViewModel&gt; ContentList { get { return _contentList; } } public CollectionViewModel() { _contentList = new ObservableCollection&lt;EntityViewModel&gt;(); _contentList.CollectionChanged += ContentCollectionChanged; } public void ContentCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Remove) { foreach(EntityViewModel item in e.OldItems) { //Removed items item.PropertyChanged -= EntityViewModelPropertyChanged; } } else if (e.Action == NotifyCollectionChangedAction.Add) { foreach(EntityViewModel item in e.NewItems) { //Added items item.PropertyChanged += EntityViewModelPropertyChanged; } } } public void EntityViewModelPropertyChanged(object sender, PropertyChangedEventArgs e) { //This will get called when the property of an object inside the collection changes } } </code></pre> <p>If you are going to need this a lot you may want to subclass your own <code>ObservableCollection</code> that triggers the <code>CollectionChanged</code> event when a member triggers its <code>PropertyChanged</code> event automatically (like it says it should in the documentation...)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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