StructureChangedEventArgs(StructureChangeType, Int32[]) Costruttore

Definizione

Inizializza una nuova istanza della StructureChangeType classe , specificando il tipo di modifica e l'identificatore (ID) dell'elemento la cui struttura è stata modificata.

public:
 StructureChangedEventArgs(System::Windows::Automation::StructureChangeType structureChangeType, cli::array <int> ^ runtimeId);
public StructureChangedEventArgs(System.Windows.Automation.StructureChangeType structureChangeType, int[] runtimeId);
new System.Windows.Automation.StructureChangedEventArgs : System.Windows.Automation.StructureChangeType * int[] -> System.Windows.Automation.StructureChangedEventArgs
Public Sub New (structureChangeType As StructureChangeType, runtimeId As Integer())

Parametri

structureChangeType
StructureChangeType

Valore singolo che specifica il tipo di modifica.

runtimeId
Int32[]

Identificatore di runtime (ID) dell'elemento Automazione interfaccia utente la cui struttura è stata modificata.

Esempio

Nell'esempio seguente viene illustrato come costruire e generare un evento quando gli elementi figlio vengono aggiunti o rimossi da una casella di riepilogo personalizzata.

/// <summary>
/// Responds to an addition to the UI Automation tree structure by raising an event.
/// </summary>
/// <param name="list">
/// The list to which the item was added.
/// </param>
/// <remarks>
/// For the runtime Id of the item, pass 0 because the provider cannot know
/// what its actual runtime Id is.
/// </remarks>
public static void OnStructureChangeAdd(CustomListControl list)
{
    if (AutomationInteropProvider.ClientsAreListening)
    {
        int[] fakeRuntimeId = { 0 };
        StructureChangedEventArgs args =
            new StructureChangedEventArgs(StructureChangeType.ChildrenBulkAdded, 
            fakeRuntimeId);
        AutomationInteropProvider.RaiseStructureChangedEvent(
            (IRawElementProviderSimple)list.Provider, args);
    }
}

/// <summary>
/// Responds to a removal from the UI Automation tree structure 
/// by raising an event.
/// </summary>
/// <param name="list">
/// The list from which the item was removed.
/// </param>
/// <remarks>
/// For the runtime Id of the list, pass 0 because the provider cannot know
/// what its actual runtime ID is.
/// </remarks>
public static void OnStructureChangeRemove(CustomListControl list)
{
    if (AutomationInteropProvider.ClientsAreListening)
    {
        int[] fakeRuntimeId = { 0 };
        StructureChangedEventArgs args =
            new StructureChangedEventArgs(StructureChangeType.ChildrenBulkRemoved, 
            fakeRuntimeId);
        AutomationInteropProvider.RaiseStructureChangedEvent(
            (IRawElementProviderSimple)list.Provider, args);
    }
}
''' <summary>
''' Responds to an addition to the UI Automation tree structure by raising an event.
''' </summary>
''' <param name="list">
''' The list to which the item was added.
''' </param>
''' <remarks>
''' For the runtime Id of the item, pass 0 because the provider cannot know
''' what its actual runtime Id is.
''' </remarks>
Public Shared Sub OnStructureChangeAdd(ByVal list As CustomListControl)
    If AutomationInteropProvider.ClientsAreListening Then
        Dim fakeRuntimeId(1) As Integer
        fakeRuntimeId(0) = 0
        Dim args As New StructureChangedEventArgs( _
            StructureChangeType.ChildrenBulkAdded, fakeRuntimeId)
        AutomationInteropProvider.RaiseStructureChangedEvent( _
            CType(list.Provider, IRawElementProviderSimple), args)
    End If

End Sub


''' <summary>
''' Responds to a removal from the UI Automation tree structure by raising an event.
''' </summary>
''' <param name="list">
''' The list from which the item was removed.
''' </param>
''' <remarks>
''' For the runtime Id of the list, pass 0 because the provider cannot know
''' what its actual runtime ID is.
''' </remarks>
Public Shared Sub OnStructureChangeRemove(ByVal list As CustomListControl)
    If AutomationInteropProvider.ClientsAreListening Then
        Dim fakeRuntimeId(1) As Integer
        fakeRuntimeId(0) = 0
        Dim args As New StructureChangedEventArgs( _
            StructureChangeType.ChildrenBulkRemoved, fakeRuntimeId)
        AutomationInteropProvider.RaiseStructureChangedEvent( _
            CType(list.Provider, IRawElementProviderSimple), args)
    End If

End Sub

Commenti

I valori che possono essere restituiti in structureChangeType dipendono dall'implementazione del provider di Automazione interfaccia utente. Ad esempio, quando gli elementi vengono aggiunti o rimossi da una casella di riepilogo Win32, se il provider non è in grado di determinare il numero di elementi aggiunti o rimossi, potrebbe specificare ChildrenInvalidated e non ChildAdded o ChildRemoved.

Nella tabella seguente vengono descritte le informazioni nell'evento ricevuto da StructureChangedEventHandler per modifiche di struttura diverse.

structureChangeType Origine evento runtimeId
ChildAdded Elemento figlio aggiunto. Elemento figlio aggiunto.
ChildRemoved Elemento padre dell'elemento figlio rimosso. Figlio rimosso.
ChildrenBulkAdded Elemento padre degli elementi figlio aggiunti. Elemento padre degli elementi figlio aggiunti.
ChildrenBulkRemoved Elemento padre degli elementi figlio rimossi. Elemento padre degli elementi figlio rimossi.
ChildrenInvalidated Elemento padre degli elementi figlio invalidati. Padre degli elementi figlio invalidati

I controlli personalizzati potrebbero non essere in grado di fornire un valore significativo in runtimeId. Per altre informazioni, vedere RaiseStructureChangedEvent.

Si applica a

Vedi anche