When you open the context menu on Canvas, you need to save the menu coordinates in MainVM.

Through events, this is done simply:

Xaml:

<Canvas ContextMenuOpening="Canvas_OnContextMenuOpening" /> 

Code-behind:

  class MainVM : ViewModelBase { public static Point ContextMenuPoint {get; set;} } //..... private void Canvas_OnContextMenuOpening(object sender, ContextMenuEventArgs e) { MainVM.ContextMenuPoint.X = e.CursorLeft; MainVM.ContextMenuPoint.Y = e.CursorTop; } 

How to do the same, but through the team?

  • @FoggyFinder; In the case of events, we simply make the ContextMenuOpening event handler. Those. I click RMB on Canvas - a context menu appears. I save the coordinates in the field of type Point , for example, pX = e.CursorLeft . Everything. In the case of teams, the concept is not clear to me. How to make a call to a command that saves coordinates when a menu appears, how to pick up menu coordinates, etc. - trydex
  • Make a command with a parameter and pass on what you need. - Bulson
  • @FoggyFinder, completed the question. - trydex
  • one
    Why save to VM? This is purely visual information. You should not want this. - VladD
  • @Bulson, can you give me an example? I do not understand how to put the menu coordinates in the parameter. - trydex

0