1

I have some element (ZedGraph) hosted in a wpf Window. I want to get the x and the y coordinate of my mousecursor. It works on the rest of the window but as soon as I hover over the Elementhost the numbers are frozen. I already found out that Elementhost does not pass the events, but I dont found a working solution to that Problem.

many thanks in advance for any hints on that problem

Andre P
  • 123
  • 1
  • 8
  • Welcome to SO Andre. Don't be shy and share the code you are using to get the position at the moment. – Jim Nov 21 '16 at 01:56

1 Answers1

0

You can use the MouseMove Event for your Page window. Let e.g the name of the Page window be mainWindow, and the Element's name be myElement1. Then you can get the position X-Y of your element and use it in comparisons with Mouse positions X-Y, like in the following example,

private void mainWindow_MouseMove(object sender, MouseEventArgs e)
{
    System.Windows.Point thepnt = new System.Windows.Point();

    thepnt = e.GetPosition(myElement1);
    if (((thepnt.X<=100)|| (thepnt.X > myElement1.Width)) || (thepnt.Y < 100))
    {
       //do something...
    }
    else
    {
       //do something else....
    }
}

Hope these help.

Jim
  • 2,974
  • 2
  • 19
  • 29
SteveTheGrk
  • 352
  • 1
  • 7