Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a DataGrid that has CanUserAddRows set to true and I use DataGridTextColumn for the cells. I can add an event handler for AddingNewItem, which fires as soon as the user leaves a cell in the new placeholder row.

The problem is I need to use DataGridTemplateColumn for the cells. This seems to completely disable the AddingNewItem event and generally breaks the whole mechanism for adding new rows (the first row is created but leaving this row does not create another new row).

How do I re-enable this or does anyone know of a good workaround?

What I have tried:

I am successfully still trapping the CurrentCellChanged event. In here, I get CurrentItem to be set to System.Windows.Data.CollectionView.NewItemPlaceholder (even though the documentation says CurrentItem never gets set to this value). I guess I can trap this event and manually add my new item to the underlying collection.

I'm experimenting so will post it as a workaround if I get something working that doesn't look horrible. Meantime, I'd love to know if I am missing something much simpler here?
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900