Sdílet prostřednictvím


SelectionItemPattern.ElementAddedToSelectionEvent Pole

Definice

Identifikuje událost vyvolanou při přidání položky do kolekce vybraných položek.

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 

Hodnota pole

Příklady

V následujícím příkladu jsou pro události deklarovány naslouchací procesy událostí 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

Poznámky

Pokud je výsledkem AddToSelection volání jedna vybraná položka, ElementSelectedEvent bude místo toho vyvolána hodnota .

Tento identifikátor používají klientské aplikace automatizace uživatelského rozhraní. Zprostředkovatelé automatizace uživatelského rozhraní by měli používat ekvivalentní pole v SelectionItemPatternIdentifiersnástroji .

Platí pro