DataGrid with CanUserAddRows=true and data binding weird behavior

Dec 11, 2008 at 4: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?
Dec 12, 2008 at 2:17 AM
See the comments section on this post, (starting with the 4th comment).  That explains a bit about what's going on.
Dec 12, 2008 at 7: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.