IRawElementProviderSimple.GetPropertyValue(Int32) Metodo

Definizione

Recupera il valore di una proprietà supportata dal provider di automazione interfaccia utente.

C#
public object GetPropertyValue(int propertyId);

Parametri

propertyId
Int32

Identificatore della proprietà.

Restituisce

Valore della proprietà o null se la proprietà non è supportata dal provider oppure NotSupported se non è mai supportata.

Esempio

Nell'esempio di codice seguente viene illustrata un'implementazione di GetPropertyValue per un controllo pulsante personalizzato.

C#
object IRawElementProviderSimple.GetPropertyValue(int propertyId)
{
    if (propertyId == AutomationElementIdentifiers.NameProperty.Id)
    {
        return "RootButtonControl";
    }
    else if (propertyId == AutomationElementIdentifiers.ClassNameProperty.Id)
    {
        return "RootButtonControlClass";
    }
    else if (propertyId == AutomationElementIdentifiers.ControlTypeProperty.Id)
    {
        return ControlType.Button.Id;  
    }
    else if (propertyId == AutomationElementIdentifiers.IsContentElementProperty.Id)
    {
        return false;
    }
    else if (propertyId == AutomationElementIdentifiers.IsControlElementProperty.Id)
    {
        return true;
    }
    else
    {
        return null;
    }
}

Commenti

Un provider deve restituire NotSupported solo se nasconde in modo esplicito il valore della proprietà e la richiesta non deve essere passata ad altri provider.

Si applica a

Prodotto Versioni
.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

Vedi anche