Expand Minimize

ScrollViewer.HorizontalSnapPointsType property

Applies to Windows and Windows Phone

Gets or sets a value that declares how manipulation behavior reacts to the snap points along the horizontal axis.

Syntax


public SnapPointsType HorizontalSnapPointsType { get; set; }


<ScrollViewer HorizontalSnapPointsType="snapPointsTypeMemberName" />

Property value

Type: SnapPointsType

A value of the enumeration. The default is None but might be set through a control template.

Remarks

For panning actions, there are often natural stopping places. Snap points provide a way to indicate where these places are. Then, when a user swipes, the manipulation result favors that natural point using behavior as expressed by a SnapPointsType value.

Proximity points (Optional and OptionalSingle): When a user is going to naturally stop the manipulation in the proximity of a snap point, proximity points help the user land at the natural stopping place. Because the user has to land in proximity to the snap point to cause it to stop there, the user will sometimes have to perform another swipe to reach a snap point.

Mandatory snap points (Mandatory and MandatorySingle): In contrast to proximity, mandatory snap points ensure that the content is adjusted to always land on a snap point. Even if the user releases the manipulation halfway between two snap-points, it will always move to one of the snap points.

To see the effects of snap points on ScrollViewer behavior yourself, get the XAML scrolling, panning and zooming sample. Run the sample on a touch device (not the simulator). Try out the SnapPointsType values when you view the "Panning with snap-points" example page of the sample.

To learn more about the swipe gesture and panning, see the "Panning behaviors" section of Guidelines for panning.

The default value of None is the default of the enumeration. If it's set, this property is often set as an attribute in a XAML template part, or as a style Setter. Each control potentially sets this differently. Getting the value at run time will provide the value that came from applied styles and templates.

Examples

This XAML is from the default template for a Hub control. A Hub has a ScrollViewer part that surrounds an ItemsStackPanel for its content. Hub uses the Optional value for its snapping behavior in both dimensions (although VerticalScrollMode is disabled in starting visual states) and disables ZoomMode. Note how the SnapPointsAlignment properties are also set as attributes here.



<ControlTemplate TargetType="Hub">
...
<ScrollViewer x:Name="ScrollViewer"
    Grid.RowSpan="2"
    HorizontalScrollMode="Auto"
    HorizontalScrollBarVisibility="Auto"
    VerticalScrollMode="Disabled"
    VerticalScrollBarVisibility="Disabled"
    HorizontalSnapPointsAlignment="Near"
    HorizontalSnapPointsType="Optional"
    VerticalSnapPointsAlignment="Near"
    VerticalSnapPointsType="Optional"
    ZoomMode="Disabled">
  <ItemsStackPanel x:Name="Panel" 
       Orientation="{TemplateBinding Orientation}"
       CacheLength="20" />
</ScrollViewer>
...
</ControlTemplate>

Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.UI.Xaml.Controls
Windows::UI::Xaml::Controls [C++]

Metadata

Windows.winmd

See also

ScrollViewer
SnapPointsType
XAML scrolling, panning and zooming sample

 

 

Show:
© 2014 Microsoft