共用方式為


ScrollPattern.ScrollPatternInformation.HorizontalScrollPercent 屬性

定義

取得目前的水平捲軸位置。

public:
 property double HorizontalScrollPercent { double get(); };
public double HorizontalScrollPercent { get; }
member this.HorizontalScrollPercent : double
Public ReadOnly Property HorizontalScrollPercent As Double

屬性值

水平捲動位置,為總計內容區域在使用者介面自動化項目中的百分比。 預設值為 0.0。

範例

在下列範例中, ScrollPattern 從目標控制項取得的物件會傳遞至函式,以擷取內容區域內可檢視區域的目前水準和垂直捲動百分比。

///--------------------------------------------------------------------
/// <summary>
/// Obtains the current scroll positions of the viewable region 
/// within the content area.
/// </summary>
/// <param name="scrollPattern">
/// The ScrollPattern control pattern obtained from the 
/// element of interest.
/// </param>
/// <returns>
/// The horizontal and vertical scroll percentages.
/// </returns>
///--------------------------------------------------------------------
private double[] GetScrollPercentagesFromPattern(
    ScrollPattern scrollPattern)
{
    if (scrollPattern == null)
    {
        throw new ArgumentNullException(
            "ScrollPattern argument cannot be null.");
    }

    double[] percentage = new double[2];

    percentage[0] =
        scrollPattern.Current.HorizontalScrollPercent;

    percentage[1] =
         scrollPattern.Current.VerticalScrollPercent;

    return percentage;
}
'''--------------------------------------------------------------------
''' <summary>
''' Obtains the current scroll positions of the viewable region 
''' within the content area.
''' </summary>
''' <param name="scrollPattern">
''' The ScrollPattern control pattern obtained from the 
''' element of interest.
''' </param>
''' <returns>
''' The horizontal and vertical scroll percentages.
''' </returns>
'''--------------------------------------------------------------------
Private Function GetScrollPercentagesFromPattern( _
ByVal scrollPattern As ScrollPattern) As Double()
    If scrollPattern Is Nothing Then
        Throw New ArgumentNullException( _
        "ScrollPattern argument cannot be null.")
    End If

    Dim percentage(1) As Double

    percentage(0) = scrollPattern.Current.HorizontalScrollPercent

    percentage(1) = scrollPattern.Current.VerticalScrollPercent

    Return percentage

End Function 'GetScrollPercentagesFromPattern

適用於