Hello,
When I click to select an XamDataGrid cell, it fires an event. How could I fire the same event again, when I click the selected cell another time?
Thanks.
To the best of my knowledge this is not possible. The event will fire when IsChanged property of the cell changes. This is the same as the row/cell activation and selection events. You could handle the PreviewMouseLeftButtonDown event and find the cell you have clicked on through the visual tree.
Thanks for your reply.
How could I find the cell I have clicked on through the visual tree? Are there any examples?
You can see how to get the CVP from a mouse click in this forum thread.
It worked, thanks.
The ActiveCell property of the XamDataGrid was null.
(xamDataGrid1.Records[cvp.Record.Index] as DataRecord).Cells[cvp.Field] worked for me.
Thank you very much.
Was the CellValuePresenter null or the ActiveCell property of the XamDataGrid null?
The CVP is just the presenter of a cell. If you want to get the presenter of the active cell, you can just use:
CellValuePresenter.FromCell(xamDataGrid1.ActiveCell);
If you want to get the cell from the CVP, then you can use the Record and Field properties exposed by the CVP.
They will give you the exact position of the represented cell and you can find it in the XamDataGrid :
(xamDataGrid1.Records[cvp.Record.Index] as DataRecord).Cells[cvp.Field]...
Just a further question, how to get the active cell from the CellValuePresenter.
I tried the following code, but the cell returned was null (XamDataGrid1 is the datagrid used in my code):
CellValuePresenter cvp = Infragistics.Windows.Utilities.GetAncestorFromType(e.OriginalSource as DependencyObject, typeof(CellValuePresenter), true) as CellValuePresenter; if (cvp != null) { Cell cell = XamDataGrid1.ActiveCell; }