title: How to Add to an ObservableCollection<T> Item with LINQ Where() in Getter?
body: <p>I recently added a Disabled property to one of my domain entities. I have a <code>List&lt;T&gt;</code> of those entities in a view model. I just changed the getter to filter the list based on a UI setting to selectively show items that are disabled.</p>
  
  <pre><code>public ObservableCollection&lt;CustomVariableGroup&gt; CustomVariableGroups
  {
      get
      {
          if (this.ShowDisabled) { return this._customVariableGroups; }
  
          return new ObservableCollection&lt;CustomVariableGroup&gt;(this._customVariableGroups.Where(x =&gt; x.Disabled == false));
      }
  }
  </code></pre>
  
  <p>The problem is that when I now try to do this (in the same view model), the item doesn't get added to the collection.</p>
  
  <pre><code>this.CustomVariableGroups.Add(newGroup);
  </code></pre>
  
  <p>And I think I know why: The newGroup is being added to the new <code>ObservableCollection&lt;T&gt;</code>, not the backing field of _customVariableGroups.</p>
  
  <p>If the LINQ Where() extension method was able to return <code>ObservableCollection&lt;T&gt;</code> (the type of the private backing field itself) instead of IEnumerable, I don't think I'd have this issue. As it stands now, since Where() returns <code>IEnumerable&lt;T&gt;</code>, I need to wrap that inside a new <code>ObservableCollection&lt;T&gt;</code>.</p>
  
  <p>What is the right/best way for me to add a new item within the same view model? Do I need to add it directly to the private backing field? I don't want to do that because I don't want to have to remember not to use the property itself.</p>