문제

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)?
도움이 되었습니까?

해결책

On a gridview for example you can implement the DragItemStarting event, and set e.Cancel = true; to prevent this behaviour - does that not meet your needs?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top