wpf窗体移动时会触发什么事件
1个回答
展开全部
采用先固定一张图片的方式,然后利用CompositionTarget.Rendering += new EventHandler(Rendering);帧刷新。
private void Carrier_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
Picture ps = _canvas.Children[0] as Picture;
//创建移动动画
if (e.LeftButton == MouseButtonState.Pressed)
{
IsMouseDown = true;
mouseX = e.GetPosition(this._canvas);
distanceY = mouseX.Y;
distanceX = mouseX.X - ps.X;//计算鼠标位置与 第一张图片的位置
oldX.X = mouseX.X;//作为计算鼠标move方向的初始值,用于决定是否可以继续拖拽,在Carrier_MouseMove函数中处理鼠标拖拽方向
CompositionTarget.Rendering += new EventHandler(MouseDownRendering);
}
}
private void Carrier_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
Picture ps = _canvas.Children[0] as Picture;
//创建移动动画
if (e.LeftButton == MouseButtonState.Pressed)
{
IsMouseDown = true;
mouseX = e.GetPosition(this._canvas);
distanceY = mouseX.Y;
distanceX = mouseX.X - ps.X;//计算鼠标位置与 第一张图片的位置
oldX.X = mouseX.X;//作为计算鼠标move方向的初始值,用于决定是否可以继续拖拽,在Carrier_MouseMove函数中处理鼠标拖拽方向
CompositionTarget.Rendering += new EventHandler(MouseDownRendering);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询