Język

StructureChangedEventArgs(StructureChangeType, Int32[]) Konstruktor

Definicja

Inicjuje nowe wystąpienie StructureChangeType klasy, określając typ zmiany i identyfikator (ID) elementu, którego struktura uległa zmianie.

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())

Parametry

structureChangeType
StructureChangeType

Pojedyncza wartość określająca typ zmiany.

runtimeId
Int32[]

Identyfikator środowiska uruchomieniowego (ID) elementu automatyzacja interfejsu użytkownika, którego struktura uległa zmianie.

Przykłady

W poniższym przykładzie pokazano, jak skonstruować i zgłaszać zdarzenie po dodaniu lub usunięciu elementów podrzędnych z pola listy niestandardowej.

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

Uwagi

Wartości, które można zwrócić w structureChangeType zależą od implementacji dostawcy automatyzacja interfejsu użytkownika. Na przykład gdy elementy są dodawane do lub usuwane z pola listy Win32, jeśli dostawca nie może określić liczby dodanych lub usuniętych elementów, może określić ChildrenInvalidated , a nie ChildAdded lub ChildRemoved.

W poniższej tabeli opisano informacje w zdarzeniu odebrane przez StructureChangedEventHandler element dla różnych zmian struktury.

structureChangeType Źródło zdarzeń runtimeId
ChildAdded Element podrzędny, który został dodany. Element podrzędny, który został dodany.
ChildRemoved Element nadrzędny elementu podrzędnego, który został usunięty. Element podrzędny, który został usunięty.
ChildrenBulkAdded Rodzic dzieci, które zostały dodane. Rodzic dzieci, które zostały dodane.
ChildrenBulkRemoved Element nadrzędny elementów podrzędnych, które zostały usunięte. Element nadrzędny elementów podrzędnych, które zostały usunięte.
ChildrenInvalidated Rodzic dzieci, które zostały unieważnione. Rodzic dzieci, które zostały unieważnione

Kontrolki niestandardowe mogą nie być w stanie podać znaczącej wartości w pliku runtimeId. Aby uzyskać więcej informacji, zobacz RaiseStructureChangedEvent.

Dotyczy

Zobacz też