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