title: gong-wpf-dragdrop - Touch - Panning Mode
body: <p>So I had a problem with <code>gong-wpf-dragdrop</code> and touch. My <code>ScrollViewer</code> was taking the events. So I fixed it with <code>ScrollViewer.PanningMode=PanningMode.None</code>, but this disabled my <code>ScrollViewer</code> - so I made a workaround.</p>
  
  <p>This behaviour checks if someone holds and presses his finger for the <code>PressTimeDuration</code>. If yes - it sets <code>ScrollViewer.PanningMode="None"</code>.</p>
  
  <pre><code>   public class ScrollViewerTouchBehaviour : System.Windows.Interactivity.Behavior&lt;FrameworkElement&gt;
      {
          public TimeSpan PressHoldDuration { get; set; } = TimeSpan.FromSeconds(1.5);
  
          private ScrollViewer CurrentScrollViewer { get; set; }
  
          protected override void OnAttached()
          {
              base.OnAttached();
              AssociatedObject.Loaded += AssociatedObject_Loaded;
          }
  
          private void AssociatedObject_Loaded(object sender, RoutedEventArgs e)
          {
              if (AssociatedObject is ScrollViewer viewer) CurrentScrollViewer = viewer;
              else CurrentScrollViewer = AssociatedObject.GetDescendantByType&lt;ScrollViewer&gt;(); ;
              if (CurrentScrollViewer == null) return;
  
              CurrentScrollViewer.TouchDown += CurrentScrollViewer_PreviewTouchDown;
          }
  
      private async void CurrentScrollViewer_PreviewTouchDown(object sender, System.Windows.Input.TouchEventArgs e)
      {
          if (sender is ScrollViewer viewer &amp;&amp; await viewer.TouchHoldAsync(PressHoldDuration))
              viewer.PanningMode = PanningMode.None;
      }
  
  
  
  
          protected override void OnDetaching()
          {
              AssociatedObject.Loaded -= AssociatedObject_Loaded;
              CurrentScrollViewer.PreviewTouchDown -= CurrentScrollViewer_PreviewTouchDown;
              CurrentScrollViewer = null;
              base.OnDetaching();
          }
      }
  </code></pre>
  
  <p>(Other stuff will take care to reset the ScrollViewer back to <code>PanningMode="VerticalFirst";</code> after DragDrop is done.)</p>
  
  <p>The function <code>TouchHoldAsync(TimeSpan timeToWait)</code> will check if the <code>ScrollViewer</code> is pressed for the <code>PressToHoldDuration</code>.</p>
  
  <p>Now my problem is - I allways have to "enable" the <code>PanningMode=None</code> by touching it once - so the event gets fired. And then I can drag and drop on the second attempt.</p>
  
  <p>So my code actually only switches the PanningMode on a long press and hold. In other words i just toggle between a "DragDropMode" and a ScrollMode.</p>
  
  <p>So how can I make it happen that I dont have to touch twice and drag and drop directly?</p>