0

There are several events which deal with manipulation (and thus drag&drop):

  • ManipulationStarting
  • ManipulationStarted
  • ManipulationDelta
  • ManipulationInertiaStarting
  • ManipulationCompleted

In the ManipulationStarting event, the event args (type ManipulationStartingRoutedEventArgs) allow me to set the Mode attribute to ManipulationModes.None -- is it correct that this means that no manipulation is allowed and thus no drag&drop?

I'm asking because I've come across a strange behaviour when I was playing with the official XAML user input events sample application, especially with scenario 4 (drag&drop).

Just set the Mode to ManipulationModes.None in the ManipulationStarting event of Scenario4.xaml.cs:

void ManipulateMe_ManipulationStarting(object sender, ManipulationStartingRoutedEventArgs e)
{
    forceManipulationsToEnd = false;
    e.Mode = ManipulationModes.None;   // <-- this is new
    e.Handled = true;
}

Nevertheless, with every third drag attempt I can drag the rectangle around. I've recorded a video to demonstrate this: http://www.youtube.com/watch?v=psytuTailHg.

This problem does not only occur with this sample but also in my own application.

Questions:

  • Why is there such a strange behavior?
  • What's the best way to cancel the drag&drop event (for instance if some conditions are not met)?
4

1 回答 1

1

例如,在 gridview 上,您可以实现 DragItemStarting 事件,并设置e.Cancel = true;为防止这种行为 - 这不符合您的需求吗?

于 2012-12-21T12:45:01.823 回答