Coming to the Surface

In my last blog entry I posted a link to the Surface Session in PDC :

This post is just to summarize some of the points with developing on surface.

Porting a WPF application to Surface

1) Add Reference to Surface assembly (Microsoft.Surface.Presentation)

Add the XML Namespace to the XAML file:

<Window x:Class="PhotoDemo.Window1"

2) Replace the controls with s:Surface.<control>

WPF Surface

The only problem with this is that the application will still be displayed one way, and not give the 360 feel users would expect with a surface. This is where the ScatterView control comes in.


To create a ScatterView around a control simply surround it with the tag:


The ScatterView contains ItemTemplates, which can bind to a DataTemplate.

e.g. for a ScatterView of Images:

<s:ScatterView Name="Scatter">
      <Image Source="{Binding}"/>

then in the code after InitializeComponent(); populate the items source (sample pictures):

public Window1()
  Scatter.ItemsSource = System.IO.Directory.GetFiles(@"c:\users\public\pictures\sample pictures", "*.jpg");

Compile, and you should see some pictures which you can move around the surface, resize and rotate.

ScatterView Additional Properties

The items within ScatterView have some additional properties:

CanScale (Boolean)
CanRotate (Boolean)
DecelerationRate (Double)

These are mostly obvious (i.e. CanScale means the user is able to enlarge and reduce the controls by dragging in opposite directions with fingers, CanRotate means the user is able to turn controls by moving fingers around in a circular motion, and DecelerationRate is how much “friction” there is on the surface when a control is thrown.

    <Style TargetType="{x:Type s:ScatterViewItem}">
      <Setter Property="CanScale"
              Value="{Binding ElementName=scale, Path=IsChecked}" />
      <Setter Property="CanRotate"
              Value="{Binding ElementName=rotate, Path=IsChecked}" />
      <Setter Property="CanScale"
              Value="{Binding ElementName=decel, Value}" />
<StackPanel Width="200" Height="120" Background="Gray">
  <s:SurfaceCheckBox Name="scale" IsChecked="True" FontSize="20">
  <s:SurfaceCheckBox Name="rotate" IsChecked="True" FontSize="20">
  <Label FontSize="20">Deceleration Rate:</Label>
  <s:SurfaceSlider Name="decel" Minimum="1" Maximum="6000" />

The Minimum and Maximum values are in device independent pixels per second per second (i.e. lower number is slippery, higher is rougher)

Tagged Objects

The final part of this session was for recognizing when objects are put onto the surface.  The items should have a tag either




The Byte tag contains 256 different ID’s, whereas the Identity Tag allows 340,282,366,920,938,000,000,000,000,000,000,000,000 different ID’s

These not only recognise a specific object, but also the position and orientation of the object.

You can create custom controls or TagVisualizer which allows custom UI’s for each Tag recognised, how to handle the object being removed form the surface.


To allocate this with a tag

      Source="<xaml file for Visualization>"
      Value="<Value written on the tag, example hex>0x40"
      PhysicalCenterOffsetFromTag="<x,y values of center offset between object and Visualization> e.g. -.23,-.4"
      OrientationOffsetFromTag="<Rotational offset between tag on object and Visualization (may be measured clockwise in degrees)>e.g. 266" />

I’ll look forward to playing around with this some more in the future (fingers crossed)

Comments (3)
  1. Joy George K says:

    I have a special scenario where the scatter view should scatter the items around the center of it.

    There should be no items floating around at the corners of scatter view.This is at the initial stage.But user can drag items to any side after loading.

    Is there something called ScatterCenter which specifies a point where the concentration of items is more…

    Thanks in advance


  2. Radu says:

    Nice article, but can you digg deeper into the situation in which you have a organisation using bussiness cards with ByteTags? How can one approach the automatisation of usage of 200 tags in a application ?

Comments are closed.

Skip to main content