Joel Palmer
Top achievements
Rank 2
Joel Palmer
asked on 13 Apr 2012, 06:02 PM
I'm using a RadContextMenu on a Canvas. When I select an item from the menu, I need to know the point in the Canvas in which I was when I opened the menu for placement of another control. How do I get the top left position of the context menu?
Thanks for your help.
Thanks for your help.
4 Answers, 1 is accepted
0
Joel Palmer
Top achievements
Rank 2
answered on 13 Apr 2012, 06:19 PM
I do have a solution but I'd prefer to not do this. I track mouse movements on the canvas and store the point into a class variable. I then use that point to capture the point in which I opened the context menu. Fortunately, when I move up and down the context menu list, the mouse position doesn't update because the menu has the focus at that point.
BTW: This is al done with the ScrollViewer I have around my canvas, not the canvas itself.
BTW: This is al done with the ScrollViewer I have around my canvas, not the canvas itself.
canvasScrollViewer.MouseMove += canvasScrollViewer_MouseMove;
Point _canvasMousePosition;
void
canvasScrollViewer_MouseMove(
object
sender, MouseEventArgs e)
{
_canvasMousePosition = e.GetPosition(canvasScrollViewer);
lblCoordinates.Content = String.Format(
"X: {0}; Y: {1}"
,
_canvasMousePosition.X, _canvasMousePosition.Y);
}
0
Hello,
You can use the MousePosition property and it will return the coordinates you clicked on. You can access them on Opened event of the RadContextMenu or some other event. This should work for your scenario.
Kind regards,
Boyan
the Telerik team
You can use the MousePosition property and it will return the coordinates you clicked on. You can access them on Opened event of the RadContextMenu or some other event. This should work for your scenario.
Kind regards,
Boyan
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Joel Palmer
Top achievements
Rank 2
answered on 31 Jul 2012, 06:50 PM
What are the coordinates in context to? I right-click on a canvas that is hosted inside a scroll viewer. Currently, when I scroll down and click on the same x/y on the canvas I the mouse position Point changes.
0
Joel Palmer
Top achievements
Rank 2
answered on 31 Jul 2012, 06:57 PM
I believe I found the problem. I set the context menu to the ScrollViewer instead of the Canvas. By asking the right question... it got me thinking down the correct path.