WindowPattern.Pattern 字段
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
标识 WindowPattern 控件模式。
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
字段值
示例
在以下示例中, WindowPattern 从某个 AutomationElement控件模式获取控件模式。
///--------------------------------------------------------------------
/// <summary>
/// Obtains a WindowPattern control pattern from an automation element.
/// </summary>
/// <param name="targetControl">
/// The automation element of interest.
/// </param>
/// <returns>
/// A WindowPattern object.
/// </returns>
///--------------------------------------------------------------------
private WindowPattern GetWindowPattern(AutomationElement targetControl)
{
WindowPattern windowPattern = null;
try
{
windowPattern =
targetControl.GetCurrentPattern(WindowPattern.Pattern)
as WindowPattern;
}
catch (InvalidOperationException)
{
// object doesn't support the WindowPattern control pattern
return null;
}
// Make sure the element is usable.
if (false == windowPattern.WaitForInputIdle(10000))
{
// Object not responding in a timely manner
return null;
}
return windowPattern;
}
'''------------------------------------------------------------------------
''' <summary>
''' Obtains a WindowPattern control pattern from an automation element.
''' </summary>
''' <param name="targetControl">
''' The automation element of interest.
''' </param>
''' <returns>
''' A WindowPattern object.
''' </returns>
'''------------------------------------------------------------------------
Private Function GetWindowPattern(ByVal targetControl As AutomationElement) As WindowPattern
Dim windowPattern As WindowPattern = Nothing
Try
windowPattern = DirectCast( _
targetControl.GetCurrentPattern(windowPattern.Pattern), _
WindowPattern)
Catch
' object doesn't support the WindowPattern control pattern
Return Nothing
End Try
' Make sure the element is usable.
If False = windowPattern.WaitForInputIdle(10000) Then
' Object not responding in a timely manner
Return Nothing
End If
Return windowPattern
End Function 'GetWindowPattern
注解
此标识符由UI 自动化客户端应用程序使用。 UI 自动化提供程序应使用等效字段。WindowPatternIdentifiers
模式标识符将传递给方法,例如 GetCurrentPattern 从指定的 AutomationElement控件模式中检索感兴趣的控制模式。