SelectionItemPattern.ElementAddedToSelectionEvent Campo

Definição

Identifica o evento gerado quando um item é adicionado a uma coleção de itens selecionados.

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 

Valor do campo

Exemplos

No exemplo a seguir, os ouvintes de eventos são declarados para os SelectionItemPattern eventos.

///--------------------------------------------------------------------
/// <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

Comentários

Se o resultado de uma AddToSelection chamada for um único item selecionado, um ElementSelectedEvent será gerado.

Esse identificador é usado por aplicativos cliente da Automação da Interface do Usuário. Os provedores de Automação da Interface do Usuário devem usar o campo equivalente em SelectionItemPatternIdentifiers.

Aplica-se a