Share via


Slider.IsSnapToTickEnabled 屬性

定義

取得或設定值,表示 Slider 是否會自動將 Thumb 移至最接近的刻度標記。

public:
 property bool IsSnapToTickEnabled { bool get(); void set(bool value); };
[System.ComponentModel.Bindable(true)]
public bool IsSnapToTickEnabled { get; set; }
[<System.ComponentModel.Bindable(true)>]
member this.IsSnapToTickEnabled : bool with get, set
Public Property IsSnapToTickEnabled As Boolean

屬性值

Boolean

如果 Slider 要求 Thumb 的位置必須是刻度標記,則為 true;否則為 false。 預設為 false

屬性

範例

下列範例會示範如何設定 IsSnapToTickEnabled 屬性。

Slider hslider = new Slider();
hslider.Width = 100;
hslider.Orientation = Orientation.Horizontal;
hslider.IsSnapToTickEnabled = true;
hslider.Minimum = 1;
hslider.Maximum = 20;
hslider.TickPlacement = TickPlacement.Both;
hslider.TickFrequency = 2;
hslider.AutoToolTipPlacement =
  AutoToolTipPlacement.BottomRight;
cv1.Children.Add(hslider);
Dim hslider As New Slider()
hslider.Width = 100
hslider.Orientation = Orientation.Horizontal
hslider.IsSnapToTickEnabled = True
hslider.Minimum = 1
hslider.Maximum = 20
hslider.TickPlacement = TickPlacement.Both
hslider.TickFrequency = 2
hslider.AutoToolTipPlacement = AutoToolTipPlacement.BottomRight
cv1.Children.Add(hslider)
<Slider Name="slider1" 
        Width="100" 
        Orientation="Horizontal" HorizontalAlignment="Left" 
        IsSnapToTickEnabled="True" Minimum="1" Maximum="20" 
        TickPlacement="Both"  TickFrequency="2"
        AutoToolTipPlacement="BottomRight"/>

備註

當 的位置 Thumb 變更且 IsSnapToTickEnabled 屬性設定 true 為 時,會自動 Thumb 將 移至最接近的刻度標記。

相依性屬性資訊

識別碼欄位 IsSnapToTickEnabledProperty
設定為 的中繼資料屬性 true

適用於