Export (0) Print
Expand All

SurfaceScrollViewer Class



Represents an area that users can scroll through and that can contain other visible elements.

Namespace: Microsoft.Surface.Presentation.Controls
Assembly: Microsoft.Surface.Presentation (in Microsoft.Surface.Presentation)

'Usage

[TemplatePartAttribute(Name="PART_ElasticBorder", Type=typeof(Border))] 
public class SurfaceScrollViewer : ScrollViewer
/** @attribute TemplatePartAttribute(Name="PART_ElasticBorder", Type=System.Windows.Controls.Border) */ 
public class SurfaceScrollViewer extends ScrollViewer
TemplatePartAttribute(Name="PART_ElasticBorder", Type=System.Windows.Controls.Border) 
public class SurfaceScrollViewer extends ScrollViewer

In the following code example, a SurfaceScrollViewer object is declared. It contains a StackPanel object with four Rectangle objects.


<s:SurfaceScrollViewer>
    <StackPanel>
        <Rectangle Width="125" Height="95" Fill="Cyan" />
        <Rectangle Width="150" Height="100" Fill="Red" />
        <Rectangle Width="135" Height="115" Fill="Blue" />
        <Rectangle Width="145" Height="120" Fill="Green" />
    </StackPanel>
</s:SurfaceScrollViewer>

SurfaceScrollViewer derives from the Microsoft Windows Presentation Foundation (WPF) ScrollViewer class, and adds Microsoft Surface-specific enhancements to the control.

Users can flick the content of a SurfaceScrollViewer control by touching the control, rapidly moving their finger a short distance, and then lifting their finger. When their finger is lifted, the content of the SurfaceScrollViewer control continues to move. The content then decelerates and comes to a stop. You can programmatically stop the movement caused by flicking by calling the StopFlick method.

You can manipulate the content of a SurfaceScrollViewer either by moving a scroll bar (like with the WPF SurfaceScrollViewer) or by direct touch interaction with the content itself. The ability to manipulate the content directly is called panning. By default, panning is enabled. You can disable it by setting the IsManipulationEnabled property to false.

When users are panning, the content moves in the same direction as the manipulating point of contact. When users use a scroll bar, the content moves in the opposite direction of the point of contact (standard control behavior).

SurfaceScrollViewer uses the SurfaceScrollInfo property to provide access to the ISurfaceScrollInfo interface. This interface extends the WPF IScrollInfo interface to provide extra methods for panning.

SurfaceScrollViewer supports elasticity, which is the ability to scroll beyond the boundaries (top, bottom, left, or right) of the content. As users scroll in this way, the ratio of touch movement to content movement increases. This behavior emulates the stretching of an elastic band; the content appears to be more difficult to move. When the touch is lifted, the content bounces back to its normal boundary. You can control the elasticity by setting the Elasticity property.

The following image shows a SurfaceScrollViewer control that is scrolled beyond the top of the content. This action occurs by touching the content itself and pulling the content down.

Flicking and elasticity work together

Dragging content down away from the SurfaceScrollViewer control

When the touch is lifted, the content bounces back to its normal boundary.

Gestures - Flick and elasticity example

Releasing the dragged content in the SurfaceScrollViewer control

Flicking and elasticity work together. If content is moving because of inertia processing that occurs after the touch is lifted from the surface, the content can move beyond a content boundary during deceleration. When the content reaches its over-scroll limit (which the Elasticity property determines), it bounces and decelerates more rapidly until coming to rest on its normal boundary.

noteNote
If you use SurfaceScrollViewer as part of another control's template, you should set the PanningModeProperty attached property on the parent control to a value other than PanningMode.None; otherwise, panning will be disabled. For example, SurfaceListBox uses SurfaceScrollViewer in its template. To enable panning, SurfaceListBox sets the PanningModeProperty attached property.

For more information, see SurfaceScrollViewer Control.


System.Object
   System.Windows.Threading.DispatcherObject
     System.Windows.DependencyObject
       System.Windows.Media.Visual
         System.Windows.UIElement
           System.Windows.FrameworkElement
             System.Windows.Controls.Control
               System.Windows.Controls.ContentControl
                 System.Windows.Controls.ScrollViewer
                  Microsoft.Surface.Presentation.Controls.SurfaceScrollViewer

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

 

Requirements

Operating System (OS)Windows 7
Software Developer Kit (SDK)Surface 2.0
.NET Framework 4
Developer environmentVisual Studio 2010, Express or full edition
Microsoft Expression Blend 4.0 (optional)
End-user hardwareDevices made for Surface 2.0, or
Windows Touch computers

Did you find this information useful? Please send us your suggestions and comments.

© Microsoft Corporation. All rights reserved.
Show:
© 2014 Microsoft