語言

AutomationElement.NameProperty 欄位

定義

識別該 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

備註

此識別碼用於 使用者介面自動化 客戶端應用程式。 使用者介面自動化提供者應使用等效的識別碼為 AutomationElementIdentifiers。

此屬性也可從 Current 或 Cached 屬性中取得。

屬性的回傳值型別 String為 。 屬性的預設值為空字串。

適用於

另請參閱