AutomationElement.NameProperty 字段
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
标识 Name 属性。
public: static initonly System::Windows::Automation::AutomationProperty ^ NameProperty;
public static readonly System.Windows.Automation.AutomationProperty NameProperty;
staticval mutable NameProperty : System.Windows.Automation.AutomationProperty
Public Shared ReadOnly NameProperty As AutomationProperty
字段值
示例
以下示例检索属性的当前值。 如果元素不提供默认值,则返回默认值。
string nameProp =
autoElement.GetCurrentPropertyValue(AutomationElement.NameProperty) as string;
Dim nameProp As String = _
CStr(autoElement.GetCurrentPropertyValue(AutomationElement.NameProperty))
下面的示例检索属性的当前值,但指定如果元素本身不提供属性的值, NotSupported 则返回而不是默认值。
string nameProp1;
object namePropNoDefault =
autoElement.GetCurrentPropertyValue(AutomationElement.NameProperty, true);
if (namePropNoDefault == AutomationElement.NotSupported)
{
nameProp1 = "No name.";
}
else
{
nameProp1 = namePropNoDefault as string;
}
Dim nameProp1 As String
Dim namePropNoDefault As Object = autoElement.GetCurrentPropertyValue(AutomationElement.NameProperty, True)
If namePropNoDefault Is AutomationElement.NotSupported Then
nameProp1 = "No name."
Else
nameProp1 = CStr(namePropNoDefault)
End If
注解
此标识符由UI 自动化客户端应用程序使用。 UI 自动化提供程序应使用 AutomationElementIdentifiers 中的等效标识符。
也可以从 Current 或 Cached 属性中检索此属性。
属性的返回值为类型 String。 属性的默认值为空字符串。