Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

ScrollPattern.ScrollPatternInformation.VerticallyScrollable Property

Retrieves a value that indicates whether the UI Automation element can scroll vertically.

Namespace: System.Windows.Automation
Assembly: UIAutomationClient (in uiautomationclient.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public bool VerticallyScrollable { get; }
/** @property */
public boolean get_VerticallyScrollable ()

public function get VerticallyScrollable () : boolean

Not applicable.

Property Value

true if the UI Automation element can scroll horizontally; otherwise false. The default value is false.

This property can be dynamic. For example, the content area of the UI Automation element might not be larger than the current viewable area, meaning VerticallyScrollable is false. However, resizing the UI Automation element or adding child items can increase the bounds of the content area beyond the viewable area, indicating that VerticallyScrollable is true.

In the following example, a ScrollPatterncontrol pattern is obtained from a UI Automation element and is then used to vertically scroll the element the requested amount.

    ///--------------------------------------------------------------------
    /// <summary>
    /// Obtains a ScrollPattern control pattern from an 
    /// automation element.
    /// </summary>
    /// <param name="targetControl">
    /// The automation element of interest.
    /// </param>
    /// <returns>
    /// A ScrollPattern object.
    /// </returns>
    ///--------------------------------------------------------------------
    private ScrollPattern GetScrollPattern(
        AutomationElement targetControl)
    {
        ScrollPattern scrollPattern = null;

        try
        {
            scrollPattern =
                targetControl.GetCurrentPattern(
                ScrollPattern.Pattern)
                as ScrollPattern;
        }
        // Object doesn't support the ScrollPattern control pattern
        catch (InvalidOperationException)
        {
            return null;
        }

        return scrollPattern;
    }

...

    ///--------------------------------------------------------------------
    /// <summary>
    /// Obtains a ScrollPattern control pattern from an automation 
    /// element and attempts to horizontally scroll the requested amount.
    /// </summary>
    /// <param name="targetControl">
    /// The automation element of interest.
    /// </param>
    /// <param name="vScrollAmount">
    /// The requested vertical scroll amount.
    /// </param>
    ///--------------------------------------------------------------------
    private void ScrollElementVertically(
        AutomationElement targetControl,
        ScrollAmount vScrollAmount)
    {
        if (targetControl == null)
        {
            throw new ArgumentNullException(
                "AutomationElement argument cannot be null.");
        }

        ScrollPattern scrollPattern = GetScrollPattern(targetControl);

        if (scrollPattern == null)
        {
            return;
        }
        
        if (!scrollPattern.Current.VerticallyScrollable)
        {
            return;
        }

        try
        {
            scrollPattern.ScrollVertical(vScrollAmount);
        }
        catch (InvalidOperationException)
        {
            // Control not able to scroll in the direction requested;
            // when scrollable property of that direction is False
            // TO DO: error handling.
        }
        catch (ArgumentException)
        {
            // If a control supports SmallIncrement values exclusively 
            // for horizontal or vertical scrolling but a LargeIncrement 
            // value (NaN if not supported) is passed in.
            // TO DO: error handling.
        }
    }

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show:
© 2015 Microsoft