DataGrid with CanUserAddRows=true and data binding weird behavior

Dec 11, 2008 at 3:16 PM
With the V1 DataGrid, even if I set CanUserAddRows="True" on the DataGrid, if the grid's ItemsSource is bound to an empty instance of a class derived only from ObservableCollection<T> and adding or overriding no functionality, no row for adding new entries shows up. If I add an entry to the collection before assigning it to the DataGrid's ItemsSource property, both rows (the added entry plus the new entry row) show up, but if I add an entry after assigning my collection to the DataGrid's ItemsSource property, then only that entry shows up (no way for the user to enter new data directly into the grid).

If I make the ItemsSource assigned value an instance of ObservableCollection<T>, with T being the same type, things work as expected both when assigning ItemsSource directly as well as via an intermediate variable. The variable, however, cannot be of the collection class ("public class TCollection : ObservableCollection<T>") but must be of the exact type ObservableCollection<T>. If it is of my collection class type, then I get the behavior described above.

In all cases AutoGenerateColumns="False" on the DataGrid, with columns explicitly defined.

This behavior seems very weird to me, and would certainly be counterintuitive to a user. Any suggestions what I might be doing wrong?
Coordinator
Dec 12, 2008 at 1:17 AM
See the comments section on this post, http://blogs.msdn.com/vinsibal/archive/2008/05/27/using-ieditablecollectionview-with-dynamically-generated-gridviewcolumns.aspx (starting with the 4th comment).  That explains a bit about what's going on.
Dec 12, 2008 at 6:31 AM
Wonderful... well, at least now that I know what is going on, I suppose I can come up with a workaround. Thank you, Vincent.