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
1410
Right mouse click to select the cell and open context menu
posted

Hi

We are using Infragistics WPF 13.2.20132.2036

I've been looking through forum but didn't find how to do this.

Right now, we have context menu inside XamDataGrid, so that when user do right mouse click, the context menu pops up.

Off course, if left-clicked on a cell, the cell selection is done.

What I want to change, is that, when user do right click on cell "x", I want to select that cell "x", and then show context menu on that cell x".

What is currently (default behaviour), is that when I right click on a cell "x" having cell "y" selected, there is no selection change, and context menu is opened "on" cell "y".

(what i mean by "on" is not GUI position, but underlying context).

The goal is to achieve the functionality of how Microsoft Excel works.

Thanks in advance for any help !!

Parents
No Data
Reply
  • 34810
    Verified Answer
    Offline posted

    Hello Lukasz,

    One option to select a cell and open a context menu on that cell is to write a Style for the XamDataGrid’s CellValuePresenter. In that Style, use an EventSetter to handle the PreviewRightMouseButtonDown event.

    In that event handler, cast the sender to a CellValuePresenter object and set the IsSelected property to true and open the context menu.

    I have attached a sample demonstrating this.

    Please let me know if you have any questions or concerns.

    Sincerely,
    Andrew
    Developer Support I
    Infragistics Inc.
    www.infragistics.com/support

    XDGContextMenuCellSelectLeftClickCase.zip
Children
No Data