IRawElementProviderSimple.GetPropertyValue(Int32) 方法

定義

擷取使用者介面自動化提供者支援的屬性值。

public:
 System::Object ^ GetPropertyValue(int propertyId);
public object GetPropertyValue (int propertyId);
abstract member GetPropertyValue : int -> obj
Public Function GetPropertyValue (propertyId As Integer) As Object

參數

propertyId
Int32

屬性識別項。

傳回

屬性值,如果此提供者不支援此屬性則為 null,如果完全不受支援則為 NotSupported

範例

下列程式碼範例顯示自訂按鈕控制項的 實 GetPropertyValue 作。

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;
    }
}
Function GetPropertyValue(ByVal propertyId As Integer) As Object _
    Implements IRawElementProviderSimple.GetPropertyValue

    If propertyId = AutomationElementIdentifiers.NameProperty.Id Then
        Return "RootButtonControl"
    ElseIf propertyId = AutomationElementIdentifiers.ClassNameProperty.Id Then
        Return "RootButtonControlClass"
    ElseIf propertyId = AutomationElementIdentifiers.ControlTypeProperty.Id Then
        Return ControlType.Button.Id
    ElseIf propertyId = AutomationElementIdentifiers.IsContentElementProperty.Id Then
        Return False
    ElseIf propertyId = AutomationElementIdentifiers.IsControlElementProperty.Id Then
        Return True
    Else
        Return Nothing
    End If

End Function 'IRawElementProviderSimple.GetPropertyValue

備註

只有當提供者明確隱藏屬性值,而且要求不會傳遞至其他提供者時,才應該傳回 NotSupported

適用於

另請參閱