I try to listen for a mouse click anywhere in my window (except where the buttons are, but I will deal with this later) and then return the point (x, y) of the location.
here is the corresponding code:
private void Grid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
Console.WriteLine("mouseLeft is clicked");
Point x = e.MouseDevice.GetPosition(this);
Console.WriteLine(x.X);
Console.WriteLine(x.Y);
}
<Canvas MouseLeftButtonDown="Grid_MouseLeftButtonDown">
When I click, nothing is printed. What am I doing wrong? The first method is inside mainWindow.Xaml.cs.
early.
source
share