SelectionItemPattern.ElementSelectedEvent 字段
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
标识在对任何 Select()、AddToSelection() 或 RemoveFromSelection() 的调用导致选定单个项时引发的事件。
public: static initonly System::Windows::Automation::AutomationEvent ^ ElementSelectedEvent;
public static readonly System.Windows.Automation.AutomationEvent ElementSelectedEvent;
staticval mutable ElementSelectedEvent : System.Windows.Automation.AutomationEvent
Public Shared ReadOnly ElementSelectedEvent As AutomationEvent
字段值
示例
在以下示例中,为 SelectionItemPattern 事件声明事件侦听器。
///--------------------------------------------------------------------
/// <summary>
/// Subscribe to the selection item events of interest.
/// </summary>
/// <param name="selectionItem">
/// Automation element that supports SelectionItemPattern and is
/// a child of a selection container that supports SelectionPattern
/// </param>
/// <remarks>
/// The events are raised by the SelectionItem elements,
/// not the Selection container.
/// </remarks>
///--------------------------------------------------------------------
private void SetSelectionEventHandlers
(AutomationElement selectionItem)
{
AutomationEventHandler selectionHandler =
new AutomationEventHandler(SelectionHandler);
Automation.AddAutomationEventHandler(
SelectionItemPattern.ElementSelectedEvent,
selectionItem,
TreeScope.Element,
SelectionHandler);
Automation.AddAutomationEventHandler(
SelectionItemPattern.ElementAddedToSelectionEvent,
selectionItem,
TreeScope.Element,
SelectionHandler);
Automation.AddAutomationEventHandler(
SelectionItemPattern.ElementRemovedFromSelectionEvent,
selectionItem,
TreeScope.Element,
SelectionHandler);
}
private void SelectionHandler(object src, AutomationEventArgs e)
{
// TODO: event handling
}
'''--------------------------------------------------------------------
''' <summary>
''' Subscribe to the selection item events of interest.
''' </summary>
''' <param name="selectionItem">
''' Automation element that supports SelectionItemPattern and is
''' a child of a selection container that supports SelectionPattern
''' </param>
''' <remarks>
''' The events are raised by the SelectionItem elements,
''' not the Selection container.
''' </remarks>
'''--------------------------------------------------------------------
Private Sub SetSelectionEventHandlers( _
ByVal selectionItem As AutomationElement)
Dim selectionHandler As AutomationEventHandler = _
New AutomationEventHandler(AddressOf OnSelectionHandler)
Automation.AddAutomationEventHandler( _
SelectionItemPattern.ElementSelectedEvent, _
selectionItem, TreeScope.Element, selectionHandler)
Automation.AddAutomationEventHandler( _
SelectionItemPattern.ElementAddedToSelectionEvent, _
selectionItem, TreeScope.Element, selectionHandler)
Automation.AddAutomationEventHandler( _
SelectionItemPattern.ElementRemovedFromSelectionEvent, _
selectionItem, TreeScope.Element, selectionHandler)
End Sub
Private Sub OnSelectionHandler(ByVal src As Object, ByVal e As AutomationEventArgs)
' TODO: event handling
End Sub
注解
此标识符由UI 自动化客户端应用程序使用。 UI 自动化提供程序应使用等效字段。SelectionItemPatternIdentifiers