title: WPF ICollectionView Filtering
body: <p>I've written a code for <strong>filtering items</strong> in ComboBox:</p>
  
  <p>My question is, how would you do that?</p>
  
  <p>I think that this solution with reflection could be very <strong>slow</strong>..</p>
  
  <pre><code>ICollectionView view = CollectionViewSource.GetDefaultView(newValue);
  view.Filter += this.FilterPredicate;
  
  
  private bool FilterPredicate(object value)
  {            
      if (value == null)
          return false;
  
      if (String.IsNullOrEmpty(SearchedText))
          return true;            
  
      int index = value.ToString().IndexOf(
          SearchedText,
          0,
          StringComparison.InvariantCultureIgnoreCase);
  
      if ( index &gt; -1) return true;
  
      return FindInProperties(new string[] { "Property1", "Property2" }, value, SearchedText);
  }
  
  private bool FindInProperties(string[] properties, object value, string txtToFind)
  {
      PropertyInfo info = null;
      for (int i = 0; i &lt; properties.Length; i++)
      {
          info = value.GetType().GetProperty(properties[i]);
          if (info == null) continue;
  
          object s  = info.GetValue(value, null);
          if (s == null) continue;
  
          int index = s.ToString().IndexOf(
              txtToFind,
              0,
              StringComparison.InvariantCultureIgnoreCase);
  
          if (index &gt; -1) return true;
      }
      return false;
  }
  </code></pre>