Getting click location
-
Hey, I want to have some surface on which the user can click, after which I get the coordinates so I can store them somewhere, and draw something on that location. I've found ways to let a user draw on something, but not how to effectively get the coordinates. This is vital for the application I want to create though. This is a C# application working with .Net 4.0 beta 2 and a WPF interface. Any pointers or suggestions in the good direction are welcome - I really want to start with the real work on that app :) Cheers!
Jeroen De Dauw --- Forums ; Blog ; Wiki --- 70 72 6F 67 72 61 6D 6D 69 6E 67 20 34 20 6C 69 66 65!
-
Hey, I want to have some surface on which the user can click, after which I get the coordinates so I can store them somewhere, and draw something on that location. I've found ways to let a user draw on something, but not how to effectively get the coordinates. This is vital for the application I want to create though. This is a C# application working with .Net 4.0 beta 2 and a WPF interface. Any pointers or suggestions in the good direction are welcome - I really want to start with the real work on that app :) Cheers!
Jeroen De Dauw --- Forums ; Blog ; Wiki --- 70 72 6F 67 72 61 6D 6D 69 6E 67 20 34 20 6C 69 66 65!
-
Hey, I want to have some surface on which the user can click, after which I get the coordinates so I can store them somewhere, and draw something on that location. I've found ways to let a user draw on something, but not how to effectively get the coordinates. This is vital for the application I want to create though. This is a C# application working with .Net 4.0 beta 2 and a WPF interface. Any pointers or suggestions in the good direction are welcome - I really want to start with the real work on that app :) Cheers!
Jeroen De Dauw --- Forums ; Blog ; Wiki --- 70 72 6F 67 72 61 6D 6D 69 6E 67 20 34 20 6C 69 66 65!
jeroen de dauw wrote:
how to effectively get the coordinates
When handling mouse events, you can use the GetPosition() method on the MouseEventArgs/MouseButtonEventArgs object to get the coordinates relative to an element. You can also use System.Windows.Input.Mouse.GetPosition() to get the current coordinates relative to an element.
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
Hey, I want to have some surface on which the user can click, after which I get the coordinates so I can store them somewhere, and draw something on that location. I've found ways to let a user draw on something, but not how to effectively get the coordinates. This is vital for the application I want to create though. This is a C# application working with .Net 4.0 beta 2 and a WPF interface. Any pointers or suggestions in the good direction are welcome - I really want to start with the real work on that app :) Cheers!
Jeroen De Dauw --- Forums ; Blog ; Wiki --- 70 72 6F 67 72 61 6D 6D 69 6E 67 20 34 20 6C 69 66 65!
-
Hey, I want to have some surface on which the user can click, after which I get the coordinates so I can store them somewhere, and draw something on that location. I've found ways to let a user draw on something, but not how to effectively get the coordinates. This is vital for the application I want to create though. This is a C# application working with .Net 4.0 beta 2 and a WPF interface. Any pointers or suggestions in the good direction are welcome - I really want to start with the real work on that app :) Cheers!
Jeroen De Dauw --- Forums ; Blog ; Wiki --- 70 72 6F 67 72 61 6D 6D 69 6E 67 20 34 20 6C 69 66 65!
I'm probably doing something stupid wrong here, but my event handler for the MouseDown event is not getting called when I click on my canvas. Anyone an idea what I'm messing up? Curious if I'm failing at C# or at WPF here :) Cheers!
Jeroen De Dauw --- Forums ; Blog ; Wiki --- 70 72 6F 67 72 61 6D 6D 69 6E 67 20 34 20 6C 69 66 65!
-
I'm probably doing something stupid wrong here, but my event handler for the MouseDown event is not getting called when I click on my canvas. Anyone an idea what I'm messing up? Curious if I'm failing at C# or at WPF here :) Cheers!
Jeroen De Dauw --- Forums ; Blog ; Wiki --- 70 72 6F 67 72 61 6D 6D 69 6E 67 20 34 20 6C 69 66 65!
Found the solution here: http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/9c8dd0c7-79fc-4de3-a116-acde79314c1e[^]
Jeroen De Dauw --- Forums ; Blog ; Wiki --- 70 72 6F 67 72 61 6D 6D 69 6E 67 20 34 20 6C 69 66 65!