title: ObservableCollection event propagation and correct usage in MVVM
body: <p>I am getting into MVVM and started out with the Prism framework and in my sample application I have typical navigation. One of the pages should list a few applications and I was wondering about differences in the implementation. To keep it simple here are some small snippets from the code thus far:</p>
  
  <p><strong>Application Model</strong></p>
  
  <pre><code>public class Application : BindableBase
  {
      private string _commandLine;
      private string _name;
      private string _smallIconSource;
  
      public string CommandLine
      {
          get { return _commandLine; }
          set { SetProperty(ref _commandLine, value); }
      }
  
      public string Name
      {
          get { return _name; }
          set { SetProperty(ref _name, value); }
      }
  
      public string SmallIconSource
      {
          get { return _smallIconSource; }
          set { SetProperty(ref _smallIconSource, value); }
      }
  }
  </code></pre>
  
  <p><strong>ApplicationPage ViewModel</strong></p>
  
  <pre><code>public class ApplicationPageViewModel : BindableBase
  {
      private ObservableCollection&lt;Application&gt; _applicationCollection;
  
      public ApplicationPageViewModel()
      {
          // load some collection entries here
      }
  
      public ObservableCollection&lt;Application&gt; ApplicationCollection
      {
          get { return _applicationCollection; }
          set
          {
              // if (_applicationCollection != null)
              //     _applicationCollection.CollectionChanged -= ApplicationCollectionChanged;
              SetProperty(ref _applicationCollection, value);
              // if (_applicationCollection != null)
              //     _applicationCollection.CollectionChanged += ApplicationCollectionChanged;
          }
      }
  }
  </code></pre>
  
  <p><strong>ApplicationPage View</strong></p>
  
  <pre><code>&lt;!-- ... --&gt;
  &lt;ItemsControl ItemsSource="{Binding ApplicationCollection}"&gt;
      &lt;ItemsControl.ItemsPanel&gt;
          &lt;ItemsPanelTemplate&gt;
              &lt;StackPanel Orientation="Vertical" /&gt;
          &lt;/ItemsPanelTemplate&gt;
      &lt;/ItemsControl.ItemsPanel&gt;
      &lt;ItemsControl.ItemTemplate&gt;
          &lt;DataTemplate&gt;
              &lt;!-- some kind of representation of applications --&gt;
              &lt;Label Content="{Binding Name}" /&gt;
          &lt;/DataTemplate&gt;
      &lt;/ItemsControl.ItemTemplate&gt;
  &lt;/ItemsControl&gt;
  &lt;!-- ... --&gt;
  </code></pre>
  
  <p>In some code samples on the internet, especially in some questions here on SO, I have seen people ask whether to store an <code>ObservableCollection</code> of ViewModels and not Models as I did - I was curious at this point when would you chose either of those version over the other one?</p>
  
  <p>Furthermore I was interested in knowing whether changes in the <code>Application</code> class reflect in the <code>ApplicationPageViewModel</code> class or if I have to hook into the <code>CollectionChanged</code> event (as seen from Brian Lagunas' Webinars where I saw this technique). So far I have only seen this hook into the <code>CollectionChanged</code> event to call the <code>RaiseCanExecuteChanged</code> method if <code>DelegateCommands</code> manually to prevent unnecesary bloat/calls when having the following implementation of <code>RelayCommand</code>s:</p>
  
  <pre><code>public event EventHandler CanExecuteChanged
  {
      add { CommandManager.RequerySuggested += value; }
      remove { CommandManager.RequerySuggested -= value; }
  }
  </code></pre>