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 自动化客户端应用程序使用。 UI 自动化提供程序应使用 中的 ValuePatternIdentifiers等效字段。
模式标识符将传递给等 GetCurrentPattern 方法,以便从指定的 AutomationElement中检索感兴趣的控件模式。