Export (0) Print
Expand All

Return Properties from a UI Automation Provider

Note Note

This documentation is intended for .NET Framework developers who want to use the managed UI Automation classes defined in the System.Windows.Automation namespace. For the latest information about UI Automation, see Windows Automation API: UI Automation.

This topic contains sample code that shows how a UI Automation provider can return properties of an element to client applications.

For any property it does not explicitly support, the provider must return null (Nothing in Visual Basic). This ensures that UI Automation attempts to obtain the property from another source, such as the host window provider.

''' <summary> 
''' Gets provider property values. 
''' </summary> 
''' <param name="propId">Property identifier.</param> 
''' <returns>The value of the property.</returns> 
Function GetPropertyValue(ByVal propId As Integer) As Object _
    Implements IRawElementProviderSimple.GetPropertyValue

    If propId = AutomationElementIdentifiers.NameProperty.Id Then 
        Return "Custom list control" 
    ElseIf propId = AutomationElementIdentifiers.ControlTypeProperty.Id Then 
        Return ControlType.List.Id
    ElseIf propId = AutomationElementIdentifiers.IsContentElementProperty.Id Then 
        Return True 
    ElseIf propId = AutomationElementIdentifiers.IsControlElementProperty.Id Then 
        Return True 
    Else 
        Return Nothing 
    End If 
End Function 'IRawElementProviderSimple.GetPropertyValue
Show:
© 2015 Microsoft