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 對等識別碼。

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

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

適用於

另請參閱