快速移动WPF窗口时,出现问题 [英] When moving the WPF window quickly, making a problem

查看:117
本文介绍了快速移动WPF窗口时,出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

请问以前的帖子.这些问题已部分解决,但出现了新问题.使用以下方法将WPF窗口快速移动到附近时,该窗口将离开鼠标光标!有什么主意吗?请指导我.

Hi all,

Excuse me for previous posts. The problems was partly solved, but a new problem has arisen. When moving the WPF window with below method to around quickly, the window be leave from the mouse cursor! is there any idea!? please guide me.

public myWindow()
{
this.InitializeComponent();

Body3D.MouseLeftButtonDown += new MouseButtonEventHandler(Body3D_MouseLeftButtonDown);
Body3D.MouseLeftButtonUp += new MouseButtonEventHandler(Body3D_MouseLeftButtonUp);
Body3D.MouseMove += new MouseEventHandler(Body3D_MouseMove);
}
bool inDrag;
Point dragPoint;
 
private void Body3D_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{ 
	dragPoint = e.GetPosition(this);
	inDrag = true; 
}
 
private void Body3D_MouseMove(object sender, MouseEventArgs e) 
{
	if (inDrag)
	{
		Point pointMoveTo;
 
		// Find the current mouse position in screen coordinates.
		pointMoveTo = this.PointToScreen(e.GetPosition(this));
 
		// Compensate for the position the control was clicked.
		pointMoveTo.Offset(-dragPoint.X, -dragPoint.Y);
 
		// Compensate for the non-client region (title bar).
		// This code is not necessary if you explicitly hide the title bar 
		// by setting the form's BorderStyle to None.
		//pointMoveTo.Offset(0, -25); //Move the window.

		this.Left  = pointMoveTo.X;
		this.Top = pointMoveTo.Y; 
	} 
} 
 
private void Body3D_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
	inDrag = false;
}} 


注意:Body3D是通过
的ModelUIElement3D 窗口
∟viewBox
∟viewPort3d
∟modelVisual3d
∟modelUIelement3d(body3D)
并将某些窗口属性设置为Background ="{x:Null}",AllowsTransparency ="True",WindowStyle ="None".

提前非常感谢.


Notice: The Body3D is a ModelUIElement3D through
window
∟viewBox
∟viewPort3d
∟modelVisual3d
∟modelUIelement3d(body3D)
and some window properties set to Background="{x:Null}", AllowsTransparency="True" , WindowStyle="None".

Thanks a lot in advance.

推荐答案

我已经在您的另一篇文章中提到了……您不能使用e.GetPosition(this).相对于参数必须是this.Left和this.Top属性的/元素.
I already stated in another of your posts...you can''t use e.GetPosition(this). The relative-to parameter needs to be the/an element the this.Left and this.Top properties are relative to!


这篇关于快速移动WPF窗口时,出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆