AutomationElement.ControlTypeProperty 欄位

定義

識別 ControlType 屬性。

public: static initonly System::Windows::Automation::AutomationProperty ^ ControlTypeProperty;
public static readonly System.Windows.Automation.AutomationProperty ControlTypeProperty;
 staticval mutable ControlTypeProperty : System.Windows.Automation.AutomationProperty
Public Shared ReadOnly ControlTypeProperty As AutomationProperty 

欄位值

範例

下列範例會擷取 屬性的目前值。 如果專案未提供預設值,則會傳回預設值。

ControlType controlTypeId = 
    autoElement.GetCurrentPropertyValue(AutomationElement.ControlTypeProperty)
    as ControlType;
Dim controlTypeId As ControlType = _
  DirectCast(autoElement.GetCurrentPropertyValue(AutomationElement.ControlTypeProperty), ControlType)

下列範例會擷取屬性的目前值,但指定如果專案本身未提供屬性的值, NotSupported 則會傳回 而不是預設值。

ControlType controlTypeId1;
object controlTypeNoDefault =
    autoElement.GetCurrentPropertyValue(AutomationElement.ControlTypeProperty, true);
if (controlTypeNoDefault == AutomationElement.NotSupported)
{
    // TODO Handle the case where you do not wish to proceed using the default value.
}
else  
{
    controlTypeId1 = controlTypeNoDefault as ControlType;
}
Dim controlTypeId1 As ControlType
Dim controlTypeNoDefault As Object = _
    autoElement.GetCurrentPropertyValue(AutomationElement.ControlTypeProperty, True)
If controlTypeNoDefault Is AutomationElement.NotSupported Then
    ' TODO Handle the case where you do not wish to proceed using the default value.
Else
    controlTypeId1 = DirectCast(controlTypeNoDefault, ControlType)
End If

備註

使用者介面自動化用戶端應用程式會使用此識別碼。 使用者介面自動化提供者應該使用 中的 AutomationElementIdentifiers 對等識別碼。

您也可以從 CurrentCached 屬性擷取這個屬性。

屬性的預設值為 Custom

適用於

另請參閱