I would like to create an input DataGrid - an empty set of rows with the column headers that can be filled with data by a user and then saved to a database. The DataGrid will not be therefore used to display data but acts like an input field. The behaviour would be similar to the one of Excell. The problem is that if the DataGrid has no data provided for it, it is not visible in the application and the user cannot enter anything. Is the DataGrid a good choice? How can this sort of functionality be implemented with a different control? I would prefer to use the DataGrid tough. Thanks a lot for any help on this.
A:
You can enter data in a DataGrid even without provided data at the start of the application. You just need the correct bindings for your ItemsSource, and set CanUserAddRows to true. Also, the class that corresponds to a row of a DataGrid must implement a parameterless constructor.
Michael Detras
2010-04-11 22:13:06
Thanks for the answer. Could you elaborate a bit on the right ItemsSource? Since I want to save the data to a database I use ItemsSource={Binding} and then use INotifyCollectionChange to update the data.
SAD
2010-04-12 07:25:42