Filtering Microsoft Surface Finger Touches for ScatterViewItems

By default, Microsoft Surface responds to any touch, including non-finger touches for example caused by a hovering hand or a sleeve touching the table. While they can be ignored using the GetIsFingerRecognized() method and setting the Handled flag of TouchEventArgs in preview touch handlers, the ScatterView seems to be somewhat special. Although you cannot move it ScatterViewItems after having intercepted and set Handled to true, items still come to the top for non-finger touches Рwhich is rather irritating.

Therefore, I implemented a CustomTopmostBehavior, an attached behavior for ScatterViewItems that solves this problem. To enable it for all ScatterViewItems of an application, simply use the following line of code:

  CustomTopmostBehavior.Activate();

Alternatively, it can be added to an existing ScatterViewItem style:

  <Style TargetType="{x:Type s:ScatterViewItem}">
    <!-- Other setters -->
    <Setter Property="local:CustomTopmostBehavior.IsEnabled" Value="True"/>
  </Style>

It ignores all non-finger touches and prevents them from bringing ScatterViewItems to the top. This can be customized by changing the CustomTopmostBehavior.TestCondition static property, which is set by default to:

  CustomTopmostBehavior.TestCondition = (t) =>
  {
     return t.GetIsFingerRecognized();
  };

Download source code.

2 thoughts on “Filtering Microsoft Surface Finger Touches for ScatterViewItems

  1. This is some excellent stuff! I did make one mod so that it works on regular touchscreens and the Surface.

      TestCondition = (t) =>
      {
        if (InteractiveSurface.PrimarySurfaceDevice.IsFingerRecognitionSupported) 
          return t.GetIsFingerRecognized(); 
        else return true;
      };

    Thanks again! Great to find some more Surface developers.

Comments are closed.