ScrollViewer.HorizontalSnapPointsType 屬性

定義

取得或設定值,這個值會宣告操作行為如何回應水準軸上的貼齊點。

public:
 property SnapPointsType HorizontalSnapPointsType { SnapPointsType get(); void set(SnapPointsType value); };
SnapPointsType HorizontalSnapPointsType();

void HorizontalSnapPointsType(SnapPointsType value);
public SnapPointsType HorizontalSnapPointsType { get; set; }
var snapPointsType = scrollViewer.horizontalSnapPointsType;
scrollViewer.horizontalSnapPointsType = snapPointsType;
Public Property HorizontalSnapPointsType As SnapPointsType
<ScrollViewer HorizontalSnapPointsType="snapPointsTypeMemberName" />

屬性值

列舉值。 預設值為 None ,但可能透過控制項範本設定。

範例

此 XAML 來自中 控制項的預設範本。 中樞ScrollViewer元件,其內容會圍繞ItemsStackPanel中樞 會針對兩個維度 (的貼齊行為使用 選擇性 值,不過 VerticalScrollMode 在開始視覺狀態) 停用 並停用 ZoomMode。 請注意 ,SnapPointsAlignment 屬性也會在這裡設定為屬性。

<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>

備註

對於移動流覽動作,通常會有自然停止的地方。 貼齊點提供一種方式來指出這些地點的位置。 然後,當使用者撥動時,操作結果會偏好使用 以 SnapPointsType 值表示的行為自然點。

**近接點 (選擇性OptionalSingle) :** 當使用者在貼齊點的鄰近性中自然停止操作時,鄰近點可協助使用者落在自然停止位置。 由於使用者必須接近貼齊點,使其停止該點,因此使用者有時必須執行另一個撥動才能到達貼齊點。

**強制貼齊點 (強制強制貼齊點) :** 相較于鄰近性,強制貼齊點可確保內容已調整為一律落在貼齊點上。 即使使用者在兩個貼齊點之間放開操作一半,它一律會移至其中一個貼齊點。

若要自行查看 ScrollViewer 行為的貼齊點效果,請取得 XAML 捲動、移動流覽和縮放範例。 在觸控裝置上執行範例, (不是模擬器) 。 當您檢視範例的 [使用貼齊點移動流覽] 範例頁面時,請嘗試 SnapPointsType 值。

若要深入瞭解撥動手勢和移動流覽,請參閱 移動流覽指導方針的一節。

[無] 的預設值是列舉的預設值。 如果已設定,此屬性通常會設定為 XAML 範本元件中的屬性,或設定為樣式 Setter。 每個控制項可能會以不同的方式設定這個。 在執行時間取得值會提供來自套用樣式和範本的值。

適用於

另請參閱