SelectionItemPattern.ElementAddedToSelectionEvent 字段
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
标识向选定项的集合添加项时引发的事件。
public: static initonly System::Windows::Automation::AutomationEvent ^ ElementAddedToSelectionEvent;
public static readonly System.Windows.Automation.AutomationEvent ElementAddedToSelectionEvent;
staticval mutable ElementAddedToSelectionEvent : System.Windows.Automation.AutomationEvent
Public Shared ReadOnly ElementAddedToSelectionEvent 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
注解
如果调用的结果 AddToSelection 是单个选定项,则会 ElementSelectedEvent 改为引发 。
此标识符由 UI 自动化客户端应用程序使用。 UI 自动化提供程序应使用 中的 SelectionItemPatternIdentifiers等效字段。