Dear support team,
I don't get the XamDataGrid to go into edit mode when clicking on the cell. The attached sample shows a XamDataGrid having an expanded cell style with another XamDataGrid. That child grid shows 3 columns with the middle column being editable. But when I click on a cell of the middle column the grid doesn't go into edit mode. Surprisingly, the cell goes into edit mode when I press Ctrl+Left Click, but this is not what our customers would expect. Please help me out whaat I can do to enter edit mode on normal left mousse click. Thanks.
0363.SelectTemplateForExpandedChildRecord.zip
Hello Tomas,
The reason why the cells don’t enter edit mode before you perform CTRL+ left click is because the XamDataGrid is inside the ExpandedCell and initially there is no active cell on which enter edit mode could be performed and the click is performed on the ExpandedCell instead of the XamDataGrid. When CTRL + left click is performed the active cell is set and enter edit mode can be performed.
In order to be able to edit cells without having to press control when clicking on a cell on the grid inside the template, what can I suggest you is handling the loaded event of the XamDataGrid inside the template. There an object of type XamDataGrid needs to be created from the sender and then the active cell of the grid needs to be set. By doing this the grid would always have an active cell and will be able to enter edit mode on just performing left click.
The code for the loaded event should be similar to the one below:
private void runtimeSettings3ColumnsGrid_Loaded(object sender, RoutedEventArgs e) { XamDataGrid xdg = sender as XamDataGrid; DataRecord dr = xdg.Records[0] as DataRecord; xdg.ActiveCell = dr.Cells[1]; }
Please let me know if you have any questions.
Regards, Ivan Kitanov