I would like to be able to select a row on right click on a cell. By default selection occurs in left click.
How can I achieve this functionality?
Thanks
Hello Sundance,
In order to select XamGrid Rows on right-click, I would recommend that you write a Style for CellControl and use an EventSetter to hook into the PreviewMouseRightButtonDown event. This Style could look like the following:
<Style TargetType="{x:Type ig:CellControl}"> <EventSetter Event="PreviewMouseRightButtonDown" Handler="CC_PreviewMouseRightButtonDown"/></Style>
The CellControl element is essentially the "presenter" for a particular cell, and you can obtain the Cell element that it is presenting by casting the above-mentioned EventHandler's sender to a CellControl and utilizing its Cell property. From the Cell, you can get the Row from the Cell's Row property and mark it's IsSelected property accordingly.
I have attached a sample project to demonstrate the above. I hope this helps you.
Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate Developer
Thank you so much. This worked perfectly.