WPF中获取鼠标相对于桌面位置

var transform = PresentationSource.FromVisual(this).CompositionTarget.TransformFromDevice;
var mouse = transform.Transform(GetMousePosition());

public System.Windows.Point GetMousePosition()
{
    System.Drawing.Point point = System.Windows.Forms.Control.MousePosition;
    return new System.Windows.Point(point.X, point.Y);
}

 

或者用PointToScreen

posted @ 2016-08-04 18:25  马语者  阅读(1211)  评论(0编辑  收藏  举报