More samples ?

Sep 2, 2008 at 12:38 PM
I still feel a lack of samples for the datagrid. Only too few available on internet. Does Microsoft plan to provide a reference sample ? Some article on MSDN maybe ?

Sep 2, 2008 at 11:25 PM
Hi Wonderliza,

There will be official DataGrid documentation available on MSDN with our .NET 4.0 release, and until that time the team will work on creating more samples and making them available on the internet through blogs, MSDN, and  If there are any particular scenarios which you are interested in, please let us know and we can work on creating samples for those scenarios.

Thank you!
Sep 3, 2008 at 10:18 AM
Edited Sep 3, 2008 at 10:19 AM
Thanks for your answer. In fact, i found nothing about the events like 
  • PreparingCellForEdit
  • BeginningEdit
  • CommitingEdit
  • CancelingEdit

    All the samples are quite simple.
    I also found nothing about when should be called the update of the database : which event should be used ?

  • Sep 3, 2008 at 2:41 PM
    For the database scenario you have access to the DataTable.RowChanged event.  Once the row is committed from the DataGrid, that event will fire which should give you the chance to update the database.  DataTable.RowChanged will handle adding rows as well.
    Sep 3, 2008 at 2:57 PM
    Do you have a code that shows how to attach DataTable.RowChanged event ?
    I only declared my datagrid this way :


    Then, i found no easy way to define the event you talk about.
    Sep 3, 2008 at 9:44 PM
    Here is one way of attaching a DataTable.RowChanged event:

                _employeeDataSet = DBAccess.GetEmployees();
                if (_employeeDataSet != null)
                    _employeeDateTable = _employeeDataSet.Tables["Employees"];
                    _employeeDateTable.RowChanged += new DataRowChangeEventHandler(employee_RowChanged);

                    DataGrid_Standard.ItemsSource = _employeeDateTable.DefaultView;

    This code is coming from a button click event that I have on my UI.  From your code snippet, it looks like your binding is coming from a higher data context.  Assuming your DataContext is a DataView you can attached it there.