3

不知道为什么会这样。我在拖放时订阅了 GiveFeedback。

在此 GiveFeedback 中,我正在检查鼠标左键的状态。如果它发布了,我想做“某事”(不重要)。

下面总是返回“鼠标按钮释放”。

我的代码:

private void GiveDragFeedback(object sender, GiveFeedbackEventArgs args)
{
  var mouseArgs = new MouseEventArgs(Mouse.PrimaryDevice, 0);

  if (Mouse.LeftButton == MouseButtonState.Pressed)
    Console.WriteLine("Mouse Button PRESSED");
  else
    Console.WriteLine("Mouse Button RELEASED");

  if (Mouse.PrimaryDevice.LeftButton == MouseButtonState.Pressed)
    _adorner_MouseMove(sender, new MouseEventArgs(Mouse.PrimaryDevice, 0));
  else
    _adorner_MouseUp(sender, mouseArgs);
}
4

1 回答 1

1

改为这样做:

 protected override void OnQueryContinueDrag(QueryContinueDragEventArgs e)
    {
        if (!e.KeyStates.HasFlag(DragDropKeyStates.LeftMouseButton))
        {
             e.Action = DragAction.Cancel;
        }
        else
        {
            e.Action = DragAction.Continue;
        }
    }
于 2015-04-24T07:01:25.453 回答