title: Binding ListBox to List (Collection) in XAML
body: <p>I'm learning WPF, so I'm kind of n00b in this.
  I saw some examples about how to do what I want to do, but nothing exactly...</p>
  
  <p>The question: I want to bind List to ListBox. I want to do it in XAML, w/o coding in code behind. How can I achieve that?</p>
  
  <p>Right now I do it <em>that way</em>:</p>
  
  <p><strong>XAML</strong></p>
  
  <pre><code>&lt;ListBox x:Name="FileList"&gt;
      &lt;ListBox.ItemTemplate&gt;
          &lt;DataTemplate&gt;
              &lt;Label Content="{Binding Path=.}"/&gt;
          &lt;/DataTemplate&gt;
      &lt;/ListBox.ItemTemplate&gt;
  &lt;/ListBox&gt;
  </code></pre>
  
  <p><strong>Code behind</strong></p>
  
  <pre><code>public MainWindow()
  {
      // ...
      files = new List&lt;string&gt;();
      FileList.ItemsSource = files;
  }
  
  private void FolderBrowser_TextChanged(object sender, RoutedEventArgs e)
  {
      string folder = FolderBrowser.Text;
      files.Clear();
      files.AddRange(Directory.GetFiles(folder, "*.txt", SearchOption.AllDirectories));
      FileList.Items.Refresh();
  }
  </code></pre>
  
  <p>But I want to get rid of <code>FileList.ItemsSource = files;</code> and <code>FileList.Items.Refresh();</code> in C# code.</p>
  
  <p>Thanks</p>