Hello,
I'd like to check whether the user has currently the last (= most bottom right) cell in the grid selected, so I can jump back the the first cell in the grid if he tabs further.
I'm currently doing it like this. However this doesn't work if the user has altered the order of the columns and moved them around, since the last cell seems to always stay the same, even if it has been moved.
Is there maybe any "better" way to do this?
Hi,
Thank you for your reply. I am glad that my sample works exactly like you wish. The deference between your code and mine is that I am handling the ‘KeyDown’ event, not the ‘PreviewKeyDown’ event of the XamDataGrid.
Please let me know, if you need any further assistance on this matter.
Thanks, that worked well. I just had to additionally subtract the number of non-visible fields from the Fields.Count.
The only issue that I have now is that grid.ExecuteCommand(DataPresenterCommands.CellFirstOverall); doesn't go into the first cell, first row but in the second cell, first row. It works in your sample, but I'm a little stumped why it doesn't work in our application. I already removed all other events from the XamDataGrid we had, to rule out any side effects. The same happens if I use CellFirstInRecord, where it jumps to the second column in the current record. Do you maybe have an idea?
I have been looking into your question and the issue in your scenario is that the field index is not changed when the field position is changed. In order to able to check the actual field position of the active cell you could you the following ‘if’ statement:
if (grid.ActiveCell.Record.Index == grid.Records.Count - 1 && grid.ActiveCell.Field.ActualPosition.Column == grid.FieldLayouts[0].Fields.Count - 1)
I am attaching a sample application(datagridActiveCellNavigation.zip) that shows my suggestion.
Let me know, if you need any further assistance on this matter.