StructureChangedEventArgs(StructureChangeType, Int32[]) Construtor

Definição

Inicializa uma nova instância da StructureChangeType classe, especificando o tipo de alteração e o identificador (ID) do elemento cuja estrutura foi alterada.

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

Parâmetros

structureChangeType
StructureChangeType

Um único valor que especifica o tipo de alteração.

runtimeId
Int32[]

O identificador de runtime (ID) do elemento Automação da Interface do Usuário cuja estrutura foi alterada.

Exemplos

O exemplo a seguir mostra como construir e gerar um evento quando as crianças são adicionadas ou removidas de uma caixa de listagem personalizada.

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

Comentários

Os valores que podem ser retornados em structureChangeType dependem da implementação do provedor de Automação da Interface do Usuário. Por exemplo, quando os itens são adicionados ou removidos de uma caixa de listagem do Win32, se o provedor não for capaz de determinar o número de itens adicionados ou removidos, ele poderá especificar ChildrenInvalidated e não ChildAdded ou ChildRemoved.

A tabela a seguir descreve as informações no evento recebido pelas diferentes alterações de StructureChangedEventHandler estrutura.

structureChangeType Origem do Evento runtimeId
ChildAdded A criança que foi adicionada. A criança que foi adicionada.
ChildRemoved O pai da criança que foi removida. A criança que foi removida.
ChildrenBulkAdded O pai das crianças que foram adicionadas. O pai das crianças que foram adicionadas.
ChildrenBulkRemoved O pai das crianças que foram removidas. O pai das crianças que foram removidas.
ChildrenInvalidated O pai das crianças que foram invalidadas. O pai das crianças que foram invalidadas

Os controles personalizados podem não ser capazes de fornecer um valor significativo em runtimeId. Para obter mais informações, consulte RaiseStructureChangedEvent.

Aplica-se a

Confira também