17,740
社区成员
发帖
与我相关
我的任务
分享
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
{
base.OnMouseLeftButtonDown(e);
// 获取鼠标相对Panel位置
Point position = e.GetPosition(this.myStackPanel);
// 如果鼠标位置在Panel内,允许拖动
if (e.LeftButton == MouseButtonState.Pressed)
{
if (position.X >= 0 && position.X < this.myStackPanel.ActualWidth && position.Y >= 0 && position.Y < this.myStackPanel.ActualHeight)
{
this.DragMove();
}
}
}