I am using Xamdatagrid. Here I have senario, where if I click on grid row, I have to redirect to Details page; and, if I click on particular cell which has text 'Incomplete' then I have to redirect to reports page.
I am using PreviewMouseLeftButtonDown event, for tracking if the cell with 'incomplete'is clicked.For the Row click, I have binded property of ICollectionView, and on EventHandler CurrentChanged, the row click is handled.
So I have 2 senario's, row click & cell click, I have been using PreviewMouseLeftButtonDown to check for the cell click. But then the rowclick does not occur.
Please, let me know the right approach, also can you suggest some alternate event for PreviewMouseLeftButtonDown.
Hello,
I am just checking if my last reply was helpful for you.
If you require any further assistance please do not hesitate to ask.
Sincerely,
Krasimir
Developer Support Engineer
Infragistics, Inc.
www.infragistics.com/support
In order to detect which cell was clicked I can suggest creating a Style for CellValuePresenter and add an EventSetter for its MouseLeftButtonDown event and put it in the XamDataGrid’s Resources section as follows:
<igDP:XamDataGrid.Resources>
<Style TargetType="{x:Type igDP:CellValuePresenter}">
<EventSetter Event="MouseLeftButtonDown" Handler="Cell_Clicked"/>
</Style>
</igDP:XamDataGrid.Resources>
And in the code behind you can add the following handler method:
void Cell_Clicked(object sender, MouseButtonEventArgs e)
{
}
By casting the sender to CellValuePresenter you check the content of the currently clicked cell by using its Value property and preform the necessary operations if the cell contents the values that require some actions.
The same approach can be used with the DataRecordPresenter in order to track which row was clicked. You can create a style with EventSetter for MouseLeftButtonDown event and put it in the XamDataGrid’s Resources section.
Infragistics