Wpf – SubSonic 3 and WPF ItemsSource (ComboBox, DataGrid) – selected item not updating more than once

comboboxselecteditemsubsonicwpf

When I bind a SubSonic 3 produced IQueryable result to the ItemsSource of a WPF ComboBox or DataGrid, I'm unable to change the selected item in the ComboBox or the DataGrid more than once. I'm using SubSonic 3.0.0.3 and ActiveRecord.

Here's an example:

In my code:

var foo = FooDB.Customer.All();
FooComboBox.ItemsSource = foo;

In my xaml:

<ComboBox DisplayMemberPath="CustomerName" Name="FooComboBox" />

Steps to reproduce:

  1. Run application. Note that there is (initially) no items selected in my ComboBox.
  2. Click on the ComboBox. The drop down appears with several customer names.
  3. Choose customer name X in the drop down. The drop down disappears and X is now selected.
  4. Click on the ComboBox again. The drop down appears.
  5. Choose customer name Y in the drop down. The drop down disappears, but X is still selected.

Thanks in advance.

Best Answer

Wrapping the SubSonic generated class with your own class (which contains one property, which gets/sets the generated class instance) and using that in a collection, works.

Related Topic