title: CollectionViewSource filtering logic in xaml
body: <p>I have a CollectionViewSource defined in xaml:</p>
  <pre><code>&lt;CollectionViewSource x:Key=&quot;DetailsViewSource1&quot; Source=&quot;{Binding DetailsList}&quot;
              xmlns:scm=&quot;clr-namespace:System.ComponentModel;assembly=WindowsBase&quot;&gt;
          &lt;CollectionViewSource.SortDescriptions&gt;
              &lt;scm:SortDescription PropertyName=&quot;AA&quot; Direction=&quot;Ascending&quot; /&gt;
              &lt;scm:SortDescription PropertyName=&quot;BB&quot; Direction=&quot;Ascending&quot; /&gt;
              &lt;scm:SortDescription PropertyName=&quot;VV&quot; Direction=&quot;Ascending&quot; /&gt;
          &lt;/CollectionViewSource.SortDescriptions&gt;
      &lt;/CollectionViewSource&gt;
  </code></pre>
  <p>And a listview using this collectionview as an ItemSource</p>
  <pre><code> &lt;ListView.ItemsSource&gt;
                      &lt;CompositeCollection&gt;
                          &lt;CollectionContainer Collection=&quot;{Binding Source={StaticResource DetailsViewSource1}}&quot; /&gt;
                          &lt;CollectionContainer Collection=&quot;{Binding Source={StaticResource DetailsViewSource2}}&quot; /&gt;
                      &lt;/CompositeCollection&gt;
                  &lt;/ListView.ItemsSource&gt;
  </code></pre>
  <p>And  a Textbox where user types the search string.
  In the viewmodels I am maintaining two observable collections, one &quot;DetailsList&quot; to which CollectionViewSource is binded and other just called &quot;actualList&quot;. Actually the idea is when user types the search string in the textbox, I change the DetailsList collection to a filtered collection, so that the list in the UI becomes the filtered one:</p>
  <pre><code>public string SeachDetailsInputString
      {
          get =&gt; _seachDetailsInputString;
          set
          {
              if (_seachDetailsInputString != value)
              {
                  _seachDetailsInputString = value;
  
                  if (!string.IsNullOrEmpty(_seachDetailsInputString))
                  {
                      var filteredList = _actualList.Where(list =&gt; list.DisplayName.Contains(value) || list.Details.Contains(value));
                      DetailsList = new ObservableCollection&lt;DetailsModel&gt;(filteredList);
                  }
                  else
                  {
                      DetailsList = _actualList;
                  }
              }
          }
      }
  </code></pre>
  <p>and when user clears the textbox I assign the DetailsList to _actualList.</p>
  <p><strong>The issue is I have to maintain two observable collection for this filtering</strong>. I want to achieve this functionality using only one. I have also seen the filter event of the CollectionViewSource, but I am not sure if this could be used in my solution.
  Moreover, I have seen that CollectionViewSource is kept in the VM code following other solutions, I would like to keep the CollectionViewSource in the xaml.</p>