none
WPF DataGrid CellEditEnding column is null RRS feed

  • Question

  •  have a datagrid that contains my observable collection of items. When I want to edit and update my cell in column ModuleType I get an empty column (null) and can't update the values in my collection and get additional errors because it didn't update.

    Am I doing something wrong or is there another way of doing this? I am pretty new to C#.

    Event Method:

    private void ModulesTable_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
        {
            Log.Debug("EDITING END");
            if (e.EditAction == DataGridEditAction.Commit)
            {
                Log.Debug("COMMIT");
                var column = e.Column as DataGridBoundColumn;
                Log.Debug("COLUMN: " + column);
                if (null != column)
                {
                    Log.Debug("NOT NULL"); // CANNOT GET IN HERE
                    var bindingPath = (column.Binding as Binding).Path.Path;
                    if (bindingPath == "Col2") 
                    {
                        int rowIndex = e.Row.GetIndex();
                        var el = e.EditingElement as ComboBox;
                        Log.Debug("RowIndex: " + rowIndex + ", Type: " + el.Text);
                    }
                }
            }
        }
    Thursday, April 2, 2020 9:39 AM

All replies

  • Did you check if e.Column is null too?

    Thursday, April 2, 2020 3:42 PM
  • Hi Stu0,
    Based on your description, it is related to WPF. So it is recommended to ask the questions in this forum and you can get more professional answer.
    Thank you for your understanding.
    Best Regards,
    Daniel Zhang


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, April 3, 2020 5:36 AM