ScrollPattern.ScrollPatternInformation.VerticalScrollPercent Property

Definition

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Gets the current vertical scroll position.

C#
public double VerticalScrollPercent { get; }

Property Value

The vertical scroll position as a percentage of the total content area within the UI Automation element. The default value is 0.0.

Examples

In the following example, a ScrollPattern object obtained from a target control is passed into a function that retrieves the current horizontal and vertical scroll percentages of the viewable region within the content area.

C#
///--------------------------------------------------------------------
/// <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;
}

Applies to

Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10