wpf 中获取鼠标坐标位置的方法

Point pointToWindow = Mouse.GetPosition(this);

Point pointToScreen = PointToScreen(pointToWindow);

this.Xtext.Text = pointToScreen.X.ToString();

this.Ytext.Text = pointToScreen.Y.ToString();


用到的是这个方法    Visual.PointToScreen Method (Point)

参考:https://msdn.microsoft.com/en-us/library/system.windows.media.visual.pointtoscreen.aspx

你可能感兴趣的:(wpf 中获取鼠标坐标位置的方法)