ValuePattern.Pattern 欄位
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
識別 ValuePattern 控制項模式。
public: static initonly System::Windows::Automation::AutomationPattern ^ Pattern;
public static readonly System.Windows.Automation.AutomationPattern Pattern;
staticval mutable Pattern : System.Windows.Automation.AutomationPattern
Public Shared ReadOnly Pattern As AutomationPattern
欄位值
範例
在下列範例中, ValuePattern 會從 AutomationElement取得控件模式。
///--------------------------------------------------------------------
/// <summary>
/// Obtains a ValuePattern control pattern from an
/// automation element.
/// </summary>
/// <param name="targetControl">
/// The automation element of interest.
/// </param>
/// <returns>
/// A ValuePattern object.
/// </returns>
///--------------------------------------------------------------------
private ValuePattern GetValuePattern(
AutomationElement targetControl)
{
ValuePattern valuePattern = null;
try
{
valuePattern =
targetControl.GetCurrentPattern(
ValuePattern.Pattern)
as ValuePattern;
}
// Object doesn't support the ValuePattern control pattern
catch (InvalidOperationException)
{
return null;
}
return valuePattern;
}
'''--------------------------------------------------------------------
''' <summary>
''' Obtains a ValuePattern control pattern from an
''' automation element.
''' </summary>
''' <param name="targetControl">
''' The automation element of interest.
''' </param>
''' <returns>
''' A ValuePattern object.
''' </returns>
'''--------------------------------------------------------------------
Private Function GetValuePattern( _
ByVal targetControl As AutomationElement) As ValuePattern
Dim valuePattern As ValuePattern = Nothing
Try
valuePattern = DirectCast( _
targetControl.GetCurrentPattern(valuePattern.Pattern), _
ValuePattern)
Catch
Return Nothing
End Try
Return valuePattern
End Function 'GetValuePattern
備註
UI 自動化用戶端應用程式會使用此識別碼。 使用者介面自動化提供者應該使用 中的 ValuePatternIdentifiers對等欄位。
模式標識符會傳遞至方法,例如從 GetCurrentPattern 指定的 AutomationElement擷取感興趣的控件模式。