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