AutomationElement.ControlTypeProperty 字段


标识 ControlType 属性。Identifies the ControlType property.

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 




下面的示例检索属性的当前值。The following example retrieves the current value of the property. 如果元素不提供默认值,则返回默认值。The default value is returned if the element does not provide one.

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

下面的示例检索属性的当前值,但指定如果元素本身不提供属性的值, NotSupported 则将返回而不是默认值。The following example retrieves the current value of the property, but specifies that if the element itself does not provide a value for the property, NotSupported is to be returned instead of a default value.

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.
    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.
    controlTypeId1 = DirectCast(controlTypeNoDefault, ControlType)
End If


此标识符由 UI 自动化客户端应用程序使用。This identifier is used by UI Automation client applications. UI 自动化提供程序应使用中的等效标识符 AutomationElementIdentifiersUI Automation providers should use the equivalent identifier in AutomationElementIdentifiers.

也可以从或属性检索此属性 Current CachedThis property can also be retrieved from the Current or Cached properties.

属性的默认值为 CustomThe default value for the property is Custom