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.
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; }
It worked, thanks.
You can see how to get the CVP from a mouse click in this forum thread.