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

前端 未结 3 1076
灰色年华
灰色年华 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 00:55

    Hi the important thing is the

    NOT on the Window

    the canvas is part of the window as well. one example:

    • the Window.AllowsTransparency state is on true
    • the Window.Background is #00000000 (completely transparent)
    • the Window.Style is None
    • the Window.State is Maximized and
    • there are NO controls or elements on the window!

    ... so if you start the application you will see Nothing now tell me how to get the mouseposition on the screen in pixel

    !Warning! if you juse Mouse.GetPosition(this); it will return x0 y0 every time

提交回复
热议问题