title: WPF Entity Framework binding
body: <p>I'm following <a href="http://msdn.microsoft.com/en-US/data/jj574514" rel="nofollow noreferrer">this tutorial</a> and trying to implement <code>Data Binding</code> using an <code>Editable ComboBox</code> instead of the <code>DataGrid</code> demonstrated in the tutorial.<br />
  The only problem I encounter is that I cannot add a new item to the DB that way.<br />
  This is how I load the data:</p>
  <pre><code>    private DbEntities db = new DbEntities();
      private void Window_Loaded(object sender, RoutedEventArgs e)
      {
          CollectionViewSource productViewSource =
              ((CollectionViewSource)(this.FindResource(&quot;productViewSource&quot;)));
  
          db.Product.Load();
  
          productViewSource.Source = db.Product.Local;
      }
  </code></pre>
  <p>and in a <code>Button_Click</code> event I tried the following methods without success:</p>
  <pre><code>    db.Product.Add(new Product() { ProductCode = &quot;&quot;, Description = &quot;&quot; });
      db.Product.Load();
      productViewSource.Source = db.Product.Local;
      productComboBox.Items.Refresh();
      productViewSource.View.MoveCurrentToLast();
  </code></pre>
  <p>and:</p>
  <pre><code>    ListCollectionView lcv = productComboBox.ItemsSource as ListCollectionView;
      lcv.AddNewItem(new Product() { ProductCode = &quot;&quot;, Description = &quot;&quot; });
      lcv.MoveCurrentToLast();
  </code></pre>
  <p>Using the <code>DataGrid</code> provided by the default <code>DataSource</code> template works as expected by adding a new item on the empty bottom row of the grid.<br />
  Please advise.</p>