Triggering the display of a toolwindow's context menu

Docking/MDI for WPF Forum

Posted 8 years ago by Gareth Parris - Software Developer, McLaren
Version: 16.1.0632
Avatar

Is there a way I can trigger the display of a toolwindow's context menu from a command?

Right clicking on my toolbar shows the context menu with my custom items in. I've added an image into my title bar context area and I want to be able to LEFT click on the image and show the same context menu.

I can see you call an internal OpenContextMenu() but there is nothing publically available. Is there someway we could access this?

[Modified 8 years ago]

Comments (6)

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Gareth,

ToolWindowContainer has a public OpenOptionsMenu method and also an OpenOptionsMenuCommand property that calls that method.


Actipro Software Support

Posted 8 years ago by Gareth Parris - Software Developer, McLaren
Avatar

Yes I can confirm that does partially what I need BUT I want to display the menu over the image I am clicking on and not the options menu icon, which is what happens when I click on the image.

The image is in the title bar context area and is positioned "near" so it is at the left most edge. The menu appears but over the options arrow on the right hand side when I use ShowOptionsMenu.

[Modified 8 years ago]

Posted 8 years ago by Gareth Parris - Software Developer, McLaren
Avatar

I've managed a bit of a hack in the meantime using...

[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
private static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint cButtons, uint dwExtraInfo);

 and...

            const int MouseEventfRightDown = 0x08;
            const int MouseEventfRightUp = 0x10;

            //Call the imported function with the cursor's current position
            var position = Mouse.GetPosition(toolWindowContainer);
            mouse_event(MouseEventfRightDown | MouseEventfRightUp, (uint)position.X, (uint)position.Y, 0, 0);

 when the image is left clicked.

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Gareth,

Quick question, why have an image and an options arrow button if both show the same thing?  It seems like it should be one or the other.

Would it help you if we added an OpenOptionsMenu method overload that took a FrameworkElement placement target?


Actipro Software Support

Posted 8 years ago by Gareth Parris - Software Developer, McLaren
Avatar

We are injecting additional items into the context menu when it is launched from the image. We don't want them in the options menu.

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Gareth,

We'll add the method overload for the next maintenance release, so that you can easily show the menu under a specified element.


Actipro Software Support

The latest build of this product (v24.1.2) was released 1 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.