I am building a simple WPF
application. I have a transparent maximized Window
and a Canvas
(canvas1).
I want to get the mouse position in canvas1
or in MainWindow
(in this case is same thing).
For doing this I use this code:
Point p = Mouse.GetPosition(canvas1); //and then I have p.X and p.Y
This code works fine for a non-transparent Canvas
. The problem is that I have a transparent Canvas
, and this code doesn't work... (It doesn't give me errors, but the coordinates are p.X = 0
and p.Y = 0
).
How can I fix this problem?