To start with, I am using VS2012 and .NET 4.5.
I am binding a DataGrid to an ObservableCollection<DataItem> and want to allow in-grid editing. I have CanUserAddRows and CanUserDeleteRows set to true. When I bind the DataGrid to the collection, the data displays perfectly (only one column of the class visible, the rest can be filled in programmatically), along with a {NewItemPlaceholder} row. I can edit existing rows and it works fine, but when I attempt to add a new row by moving to the placeholder, entering a value, and then hitting enter, nothing happens. That is, the new value is displayed, but the AddingNewItem event never fires, the new row isn't added to the underlying collection, and no new {NewItemPlaceholder} row is added to the DataGrid.
I'm probably doing (or, more accurately, NOT doing) something stupid, but I haven't done a lot of work with DataGrids, so I'm looking for a hand.
Do I have to manually implement the add functionality? If so, is there a built-in event to tell me when to do that, or do I have to do something kludgy like trap the enter key and use that to fire the manual add functionality? Or am I just missing something fairly simple?
I am binding a DataGrid to an ObservableCollection<DataItem> and want to allow in-grid editing. I have CanUserAddRows and CanUserDeleteRows set to true. When I bind the DataGrid to the collection, the data displays perfectly (only one column of the class visible, the rest can be filled in programmatically), along with a {NewItemPlaceholder} row. I can edit existing rows and it works fine, but when I attempt to add a new row by moving to the placeholder, entering a value, and then hitting enter, nothing happens. That is, the new value is displayed, but the AddingNewItem event never fires, the new row isn't added to the underlying collection, and no new {NewItemPlaceholder} row is added to the DataGrid.
I'm probably doing (or, more accurately, NOT doing) something stupid, but I haven't done a lot of work with DataGrids, so I'm looking for a hand.
Do I have to manually implement the add functionality? If so, is there a built-in event to tell me when to do that, or do I have to do something kludgy like trap the enter key and use that to fire the manual add functionality? Or am I just missing something fairly simple?