title: How do I bind an ObservableCollection to a ComboBox?
body: <p>How do I get even basic binding to work between a <code>ComboBox</code> and an <code>ObservableCollection</code>? I can't get anything but error messages.</p>
  
  <p>VB:</p>
  
  <pre><code>Class MainWindow
      Dim Units As New ObservableCollection(Of String)
  
      Private Sub Window_Loaded(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded
          Units.Clear()
          Units.Add("in")
          Units.Add("mm")
          Units.Add("cm")
      End Sub
  End Class
  </code></pre>
  
  <p>XAML:</p>
  
  <pre><code>&lt;Window x:Class="MainWindow"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  Title="MainWindow" Height="350" Width="525"&gt;
  &lt;Grid&gt;
      &lt;ComboBox Height="59" HorizontalAlignment="Left" Margin="136,96,0,0" Name="ComboBox1" VerticalAlignment="Top" Width="319"
                ItemsSource="{Binding Units}"/&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p></p>
  
  <p>No matter what I do, the <code>ComboBox</code> always seems to be empty and there's an error message in the console:</p>
  
  <blockquote>
    <p>System.Windows.Data Error: 40 : BindingExpression path error: 'Units' property not found on 'object' ''MainWindow' (Name='')'. BindingExpression:Path=Units; DataItem='MainWindow' (Name=''); target element is 'ComboBox' (Name='ComboBox1'); target property is 'ItemsSource' (type 'IEnumerable')</p>
  </blockquote>