This documentation is archived and is not being maintained.

Return Properties from a UI Automation Provider

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.

Example

/// <summary>
/// Gets provider property values.
/// </summary>
/// <param name="propId">Property identifier.</param>
/// <returns>The value of the property.</returns>
object IRawElementProviderSimple.GetPropertyValue(int propId)
{
    if (propId == AutomationElementIdentifiers.NameProperty.Id)
    {
        return "Custom list control";
    }
    else if (propId == AutomationElementIdentifiers.ControlTypeProperty.Id)
    {
        return ControlType.List.Id;  
    }
    else if (propId == AutomationElementIdentifiers.IsContentElementProperty.Id)
    {
        return true;
    }
    else if (propId == AutomationElementIdentifiers.IsControlElementProperty.Id)
    {
        return true;
    }
    else
    {
        return null;
    }
}

See Also

Show: