AutomationElement.Current 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得 AutomationElement 目前的屬性值。
public:
property System::Windows::Automation::AutomationElement::AutomationElementInformation Current { System::Windows::Automation::AutomationElement::AutomationElementInformation get(); };
public System.Windows.Automation.AutomationElement.AutomationElementInformation Current { get; }
member this.Current : System.Windows.Automation.AutomationElement.AutomationElementInformation
Public ReadOnly Property Current As AutomationElement.AutomationElementInformation
屬性值
包含目前屬性值的結構。
例外狀況
AutomationElement 的 UI 不再存在。
範例
下列範例示範如何使用 Current 屬性來擷取清單中已選取的專案名稱。
/// <summary>
/// Handles ElementSelected events by showing a message.
/// </summary>
/// <param name="src">Object that raised the event; in this case, a list item.</param>
/// <param name="e">Event arguments.</param>
private void OnSelect(object src, AutomationEventArgs e)
{
// Get the name of the item, which is equivalent to its text.
AutomationElement element = src as AutomationElement;
if (element != null)
{
Console.WriteLine(element.Current.Name + " was selected.");
}
}
''' <summary>
''' Handles ElementSelected events by showing a message.
''' </summary>
''' <param name="src">Object that raised the event; in this case, a list item.</param>
''' <param name="e">Event arguments.</param>
Private Sub OnSelect(ByVal src As Object, ByVal e As AutomationEventArgs)
' Get the name of the item, which is equivalent to its text.
Dim element As AutomationElement = DirectCast(src, AutomationElement)
If (element IsNot Nothing) Then
Console.WriteLine(element.Current.Name + " was selected.")
End If
End Sub
備註
消費者介面自動化屬性的存取子會表示為 所 Current 傳回結構的屬性。 您不需要擷取 結構;您可以直接存取其成員,如下列範例所示。 如需可用屬性及其使用的特定資訊,請參閱 AutomationElement.AutomationElementInformation 。
若要取得這個專案上消費者介面自動化屬性的快取值,請使用 Cached 屬性。