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

注解

UI 自动化客户端应用程序使用此标识符。 UI 自动化提供程序应使用 中的 AutomationElementIdentifiers等效标识符。

也可以从 CurrentCached 属性检索此属性。

属性的默认值为 Custom

适用于

另请参阅