Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
405
Select xamgrid row in cell right click
posted

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

Parents
No Data
Reply
  • 34810
    Verified Answer
    Offline posted

    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,
    Andrew
    Associate Developer

    XamGridRightClickSelection.zip
Children