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)

'Declaration
Public ReadOnly Property VerticallyScrollable As Boolean

Property Value

Type: System.Boolean
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 ScrollPattern control 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 Function GetScrollPattern( _
ByVal targetControl As AutomationElement) As ScrollPattern
    Dim scrollPattern As ScrollPattern = Nothing 

    Try
        scrollPattern = DirectCast( _
        targetControl.GetCurrentPattern(scrollPattern.Pattern), _
        ScrollPattern)
    Catch 
        ' Object doesn't support the ScrollPattern control pattern 
        Return Nothing 
    End Try 

    Return scrollPattern

End Function 'GetScrollPattern


...


'''-------------------------------------------------------------------- 
''' <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 Sub ScrollElementVertically( _
ByVal targetControl As AutomationElement, _
ByVal vScrollAmount As ScrollAmount)
    If targetControl Is Nothing Then 
        Throw New ArgumentNullException( _
        "AutomationElement argument cannot be null.")
    End If 

    Dim scrollPattern As ScrollPattern = GetScrollPattern(targetControl)

    If scrollPattern Is Nothing Then 
        Return 
    End If 

    If Not scrollPattern.Current.VerticallyScrollable Then 
        Return 
    End If 

    Try
        scrollPattern.ScrollVertical(vScrollAmount)
    Catch exc As InvalidOperationException
        ' Control not able to scroll in the direction requested; 
        ' when scrollable property of that direction is False 
        ' TO DO: error handling. 
    Catch exc As 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. 
    End Try 

End Sub 'ScrollElementVertically 

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft