我需要拖动一个WPF元素并插入另一个WPF目标元素。我一直在测试代码中使用InputSimulator进行所有键盘交互。但是没有找到任何关于用InputSimulator拖动鼠标的东西。对此有何见解?
答案 0 :(得分:0)
您可以使用Mouse Class中的本机编码ui方法。像,
根据OP请求编辑:
// Determine drop coordinates dynamically
Point dropDestinationPoint = controlYouWanttoDropOn.GetClickablePoint();
// Add some buffer to avoid possible clicking over the edges - Optional
dropDestinationPoint.X += 5;
dropDestinationPoint.Y += 5;
Mouse.StartDragging(controlYouWantToDrag);
Mouse.StopDragging(controlYouWanttoDropOn, dropDestinationPoint);
您也可以尝试通过BoundingRectangle属性获取点数并使用它。