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:
- Run application. Note that there is (initially) no items selected in my ComboBox.
- Click on the ComboBox. The drop down appears with several customer names.
- Choose customer name X in the drop down. The drop down disappears and X is now selected.
- Click on the ComboBox again. The drop down appears.
- 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.