This is a migrated thread and some comments may be shown as answers.

Position context menu

5 Answers 126 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Rajesh
Top achievements
Rank 1
Rajesh asked on 19 Feb 2010, 09:54 AM
Hi

In one of my application, I am using Mind fusion diagramming control. This diagramming control allows user to add various shapes and lines. When the user clicks on shape or line small rectangle (adjustment handles) gets added dynamically on the main diagram control. I cannot use RadContextMenu.SetContextMenu function for these small rectanagles since they are created/destroyed by the diagram control.

With there sub-classing behaviour, I know when user clicks on adjusment handle and raises the event. In this event, I want to show the popup. How I can achive this ?

How one can set the mouse position where to display the popup and all other necessary information like which UIElement should be the parent of this context menu. 

Regards
Rajesh

5 Answers, 1 is accepted

Sort by
0
Konstantina
Telerik team
answered on 24 Feb 2010, 02:32 PM
Hi Rajesh,

Thank you for contacting us.

To use the ContextMenu on your elements, you can set it to the diagramming control. Set the EventName property of the ContextMenu to an empty string like so: EventName="".
In the event that the element of the diagramming controls raises you can show the ContextMenu by setting IsOpen=true. You cannot change the UIElement, but in that event you can change the ItemsSource of the ContextMenu according to the figure the user has clicked.

Hope that helps.

If you have any other questions please feel free to contact us again.

Greetings,
Konstantina
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Rajesh
Top achievements
Rank 1
answered on 25 Feb 2010, 07:12 AM
Hi

I am able to get the popup displayed but it is not at the correct location. It always gets displayed in upper left corner of the diagram element.

-Rajesh
0
Konstantina
Telerik team
answered on 02 Mar 2010, 01:43 PM
Hi Rajesh,

Thank you for contacting us.

Could you please open a support ticket and send us a sample project, which we can run here locally. In that way we will be able to provide you with the best solution.

Looking forward to your reply.

Regards,
Konstantina
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Klaas van der Heijden
Top achievements
Rank 1
answered on 30 Jul 2013, 11:37 AM
 Hi,

 I have exact situation; I am using Mind fusion diagramming control. This diagramming control allows user to add various shapes and lines. I am using RadContextMenu to show menu items for lines and shapes. Menu Items are created at the run time based on clicked item [shape or line]. it shows the context menu correctly but not display on proper position.

Below steps I have followed
1.   public RadContextMenu contextMenu = new RadContextMenu() { EventName = "" };  
2.   Create Menu List and added to contextMenu 
3.   contextMenu.IsOpen = true;

I have upgraded to 2013 [Version 2013.2.611.1050], before upgrade it works properly.

how can I set the Mouse Position to context menu to display context menu at Mouse [right] clicked position?


Thanks

0
Rosen Vladimirov
Telerik team
answered on 30 Jul 2013, 01:37 PM
Hello Klaas,

RadContextMenu has Placement, PlacementTarget and PlacementRectangle properties that you can use. When you open RadContextMenu via code by setting IsOpen=true, you have two options to control the position where the Popup will be:
1) Set PlacementTarget property - for example you can set it to the current shape and RadContexMenu will be shown below it.
2) Handle one of the mouse events on the control and set PlacementRectangle property. In order to get the position of the mouse, you'll need one of the mouse events (MouseLeftButtonDown, MouseLeftButtonUp, etc). In the event handler you can use the code below:
Point mousePosition = e.GetPosition(null);
 
this.ContextMenu.PlacementRectangle = new Rect(mousePosition.X, mousePosition.Y, 0, 0);
this.ContextMenu.IsOpen = true;

This will open the ContextMenu right below the mouse (as the PlacementRectangle has width=0 and height=0).

I'm sending you a sample project to demonstrate this approach. Could you check it and inform us in case you have any problems or concerns.

Regards,
Rosen Vladimirov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
Menu
Asked by
Rajesh
Top achievements
Rank 1
Answers by
Konstantina
Telerik team
Rajesh
Top achievements
Rank 1
Klaas van der Heijden
Top achievements
Rank 1
Rosen Vladimirov
Telerik team
Share this question
or