title: WPF MVVM - Stop value from updating on the UI
body: <p>I want to freeze/unfreeze my data in a listview which is receiving polling data every few seconds. I have a button that will freeze/unfreeze the panel, but I want a way to stop the panel from updating visibly in the UI, but continue to have the collection updated in the code under the hood as normal. I tried to change the setter for my bound object, however, it doesn't get hit when I am doing the following:</p>
  <pre><code>      Output.Insert(0, newMessage);
  
        if (Output.Count &gt; this.maxOutputItemCount)
        {
          Output.RemoveAt(this.maxOutputItemCount);
        }
  </code></pre>
  <p>Where <code>Output</code> is the observable collection.</p>
  <p>This is the setter that doesn't get hit each time the insert happens, which means the frozen check is ineffective:</p>
  <pre><code>    private ObservableCollection&lt;PDMessageModel&gt; output;
      public ObservableCollection&lt;PDMessageModel&gt; Output
      {
        get =&gt; this.output;
        set
        {
          if (value == this.output)
          {
            return;
          }
  
          this.output = value;
  
          if (!isFrozen)
          {
            RaisePropertyChanged();
          }
        }
      }
  </code></pre>
  <p>I created a function that listens to the <code>CollectionChanged</code> function of <code>ObservableCollection</code> but not sure how I can use this to my advantage...</p>
  <p>I have also tried changing to <code>List</code>:</p>
  <pre><code>    public List&lt;PDMessageModel&gt; Output { get; private set; }
  </code></pre>
  <p>And changing the code like so:</p>
  <pre><code>      if (isFrozen)
        {
          return;
        }
  
        Output.Insert(0, newMessage);
  
        if (Output.Count &gt; this.maxOutputItemCount)
        {
          Output.RemoveAt(this.maxOutputItemCount);
        }
        RaisePropertyChanged(nameof(Output));
  </code></pre>
  <p>But the UI is not updating when RaisePropertyChanged is called.</p>
  <p>Changing the code to this using a list works:</p>
  <pre><code>      if (isFrozen)
        {
          return;
        }
  
        List&lt;PolledDataMessageModel&gt; outputCopy = new List&lt;PolledDataMessageModel&gt;(Output);
        outputCopy.Insert(0, newMessage);
  
        if (outputCopy.Count &gt; this.maxOutputItemCount)
        {
          outputCopy.RemoveAt(this.maxOutputItemCount);
        }
        Output = outputCopy;
  </code></pre>
  <p>Though I don't know if that's preferred over using ObservableCollection and having suppression of notifications.</p>
  <p>Has anyone got any ideas or a better way of doing this?</p>
  <p>Thanks!</p>