title: Using MVVM, how to notify other properties and commands when a collection was modified
body: <p>In à program written in C# and Xamarin Forms (but this question is more based on MVVM), I have an ObservableCollection of Items:</p>
  
  <pre><code>        ObserbableCollection&lt;Item&gt; Items { get; set; }
  </code></pre>
  
  <p>When this collection changes (an item is added or removed to/from the collection), I need to notify other properties and commands because they are all binded to controls on a XAML screen (mostly buttons and labels).</p>
  
  <p>The only solution I found was something like this:</p>
  
  <pre><code>        Items.CollectionChanged += (sender, args) =&gt;
          {
              ((Command)OnHoldCommand).ChangeCanExecute();
              ((Command)CancelSaleCommand).ChangeCanExecute();
              ((Command)ValidateTakeAwayCommand).ChangeCanExecute();
              ((Command)ValidateEatInCommand).ChangeCanExecute();
              RaisePropertyChanged(() =&gt; TotalItems);
              RaisePropertyChanged(() =&gt; TotalAmount);
          };
  </code></pre>
  
  <p>Do you think there is another solution? Maybe using Fody.PropertyChanged?</p>
  
  <p>I use FreshMvvm as Mvvm framework on top of Xamarin Forms.</p>