title: Collection ViewSource to filter listbox by typing in textbox
body: <p>I have a listbox in WPF where users firstname and lastname are listed.  I have a textbox, and I am trying to filter as I type by the names.  Here is what I am trying:  (Nothing is being filtered when I am typing in the textbox)</p>
  
  <p>Here is my VM</p>
  
  <pre><code>        #region Members
  
          private CollectionViewSource usercvs = new CollectionViewSource();
          private string searchString;
  
          #endregion
  
          #region Properties
  
          public string SearchFilter
          {
              get
              {
                  return this.searchString;
              }
  
              set
              {
                  if (!string.IsNullOrEmpty(this.searchString))
                      AddFilter();
  
                  usercvs.View.Refresh();    
                  this.searchString = value;
              }
          }
  
          #endregion
  
          #region Methods
  
          private void AddFilter()
          {
              usercvs.Filter -= new FilterEventHandler(Filter);
              usercvs.Filter += new FilterEventHandler(Filter);
  
          }
  
          private void Filter(object sender, FilterEventArgs e)
          {
              // see Notes on Filter Methods:
              var src = e.Item as User;
              if (src == null)
                  e.Accepted = false;
              else if (src.LastName != null &amp;&amp; !src.LastName.Contains(SearchFilter))
                  e.Accepted = false;
          }
  
          #endregion
      }
  }
  </code></pre>