The error message alone gives it away - your binding has the wrong context.
You're setting the DataContext
of your window to customerVm.Customers
in the loaded method. That means that your bindings "start" from the Customers
property already, and so the binding on your grid is actually trying to find customerVm.Customers.Customers
. That's why you get the error message you do: an ObservableCollection
has no Customers
property.
You can either change it so the DataContext
set in code is simply customerVm
, or use ItemsSource={Binding}
on the DataGrid (which will then just pick up the current DataContext
).
Dan Puzey
2010-07-03 09:51:44