title: Filtering a xaml list box
body: <p>Hi I have a list box with some customer names, I want to filter the list based on the text entered in the TextBox. After researching a bit I heard that we can use CollectionViewSourse and ICollectionView but did not get a stage where I could get it working. </p>
  
  <p>Could you please suggest on how to achieve this.</p>
  
  <p>Your help is much appreciated.</p>
  
  <p>XAML</p>
  
  <pre><code> &lt;TextBox x:Name="txtSearch"/&gt;
   &lt;ListBox x:Name="lbCustomers"&gt;
  </code></pre>
  
  <p>XAML.cs</p>
  
  <pre><code>List&lt;string&gt; customerList;
      public MainPage()
      {
          this.InitializeComponent();
          customerList = new List&lt;string&gt;();
          customerList.Add("Andrew");
          customerList.Add("bravo");
          customerList.Add("Carol");
          customerList.Add("Dela");
          customerList.Add("Eva");
          customerList.Add("family");
          customerList.Add("George");
          customerList.Add("Health");
          customerList.Add("Illa");
          customerList.Add("Jack");
          customerList.Add("Andrew");
          lbCustomers.ItemsSource = customerList;
  
          CollectionViewSource collectionViewSource = new CollectionViewSource();
          collectionViewSource.Source = customerList;
          ICollectionView collectionView = collectionViewSource.View;
      }
  </code></pre>
  
  <p>Edit:
  I can not access 'CollectionViewSource.GetDefaultView' and 'view.Filter'. I get an error : 'collectionviewsource does not contain a definition for getdefaultview'</p>
  
  <p>When I looked into the definition i did not find the 'GetDefaultView' and 'Filter dependency properties'</p>
  
  <pre><code> public sealed class CollectionViewSource : DependencyObject, ICollectionViewSource
  {
      public CollectionViewSource();
  
      public static DependencyProperty IsSourceGroupedProperty { get; }
      public static DependencyProperty ItemsPathProperty { get; }
      public static DependencyProperty SourceProperty { get; }
      public static DependencyProperty ViewProperty { get; }
      public System.Boolean IsSourceGrouped { get; set; }
      public PropertyPath ItemsPath { get; set; }
      public System.Object Source { get; set; }
      public ICollectionView View { get; }
  }
  </code></pre>