Search code examples
wpfsortingdatagriddatagridtemplatecolumnemptydatatext

WPFDataGrid behaves strangely with DataGridTemplateColumn sorting after editing the cell content


I am facing a problem with WPFDataGrid. I have bound my DataGrid to XML data. I am using DataGridTemplateColumn for all the columns.

After the initial data is loaded everything(like sorting, etc) works fine. Then once I edit some cell say a TextBox in template column and then try to sort the grid, the cell which contains the TextBox have empty data!! (I mean the TextBox becomes empty). This happens whenever I edit any cell.

Is it a bug in WPFDataGrid? I am sure many people who use template columns would have faced it. Urgent help required !!!!


Solution

  • I just had to add this to my DataGrid declaration

     SelectionUnit="Cell"
    

    It solved my problem !!!