Get Mouse Position on Canvas (But NOT on window)?

前端 未结 3 1079
灰色年华
灰色年华 2020-12-06 00:41

I have a project in WPF 4 and vb.net 2010.

I have a canvas inside a window. The window is full screen, but the canvas is set to a solid 640x480 in the center of the

3条回答
  •  南笙
    南笙 (楼主)
    2020-12-06 01:15

    so I solved the Problem by using System.Windows.Forms.Control.MousePosition it's a bit a mix of wpf and Windows.Forms but I've given up xD.

    Sorry for yelling :/

    To make it easy for me I made a Extension:

     _
     _
    Public Function toWfpPoint(p As System.Drawing.Point) As Point
        Return new Point(p.X, p.Y)
    End Function
    

    Now I just can juse it like this:

    Dim MousPos As Point = System.Windows.Forms.Control.MousePosition.toWfpPoint
    

提交回复
热议问题