快速移动WPF窗口时

快速移动WPF窗口时

本文介绍了快速移动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.

推荐答案


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

08-29 04:39