Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. Getting click location

Getting click location

Scheduled Pinned Locked Moved WPF
csharpwpfcombeta-testingtutorial
6 Posts 3 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jeroen De Dauw
    wrote on last edited by
    #1

    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!

    L M J 4 Replies Last reply
    0
    • J Jeroen De Dauw

      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!

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      This article (demo) here at The Code Project probability has every example you are looking for. It's a really nice diagramming application in the works. WPF Diagram Designer - Part 2[^]

      1 Reply Last reply
      0
      • J Jeroen De Dauw

        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!

        M Offline
        M Offline
        Mark Salsbery
        wrote on last edited by
        #3

        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:

        1 Reply Last reply
        0
        • J Jeroen De Dauw

          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!

          J Offline
          J Offline
          Jeroen De Dauw
          wrote on last edited by
          #4

          Hey guys, I did search for such a method, and didn't find one. Guess why... Somehow I managed to click the KeyDown event instead of the MouseDown one :omg: Anyway, thanks for the helping :) 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!

          1 Reply Last reply
          0
          • J Jeroen De Dauw

            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!

            J Offline
            J Offline
            Jeroen De Dauw
            wrote on last edited by
            #5

            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!

            J 1 Reply Last reply
            0
            • J Jeroen De Dauw

              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!

              J Offline
              J Offline
              Jeroen De Dauw
              wrote on last edited by
              #6

              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!

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups