SelectionItemPattern.ElementSelectedEvent Champ
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Identifie l’événement qui est déclenché quand un appel à Select(), AddToSelection(), ou RemoveFromSelection() aboutit à la sélection d’un seul élément.
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
Valeur de champ
Exemples
Dans l’exemple suivant, les écouteurs d’événements sont déclarés pour les SelectionItemPattern événements.
///--------------------------------------------------------------------
/// <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
Remarques
Cet identificateur est utilisé par UI Automation applications clientes. UI Automation fournisseurs doivent utiliser le champ équivalent dans SelectionItemPatternIdentifiers.