title: Static object: manage set method
body: <p>I have a static observableCollection.</p>
  
  <p>It is updated from the UI, using a MVVM approach.</p>
  
  <p>How can I understand when a mod is made? (I need to change the value of a boolean flag when a change is made)</p>
  
  <p>This is my code:</p>
  
  <pre><code>public static event EventHandler serbatoiDisponibiliPerErogatoriChanged;
  private static ObservableCollection&lt;TabSerbatoi&gt; p_serbatoiDisponibiliPerErogatori = new ObservableCollection&lt;TabSerbatoi&gt;();
  public static ObservableCollection&lt;TabSerbatoi&gt; serbatoiDisponibiliPerErogatori
  {
      get { return p_serbatoiDisponibiliPerErogatori; }
      set
      {
          p_serbatoiDisponibiliPerErogatori = value;
          if (serbatoiDisponibiliPerErogatoriChanged != null)
              serbatoiDisponibiliPerErogatoriChanged(null, EventArgs.Empty);
      }
  }
  </code></pre>
  
  <p>I have also tried to match a function to the event serbatoiDisponibiliPerErogatoriChanged, but it is never called, because, with the debug, I have seen that it entes in the set method only at the init of the window. </p>
  
  <p>The weird point is that the obeservableCollection is correctly updated, but it never passes in the set method.</p>
  
  <p>How can I do it? </p>
  
  <p>UPDATE:</p>
  
  <p>with the mot's answer, I have done this:</p>
  
  <pre><code>void test(object sender, NotifyCollectionChangedEventArgs e)
  {
      Debug.WriteLine("test");
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>serbatoiDisponibiliPerErogatori.CollectionChanged += test;
  </code></pre>
  
  <p>but, again, it is never called... it never enters in the "test" function.. why?</p>