StructureChangedEventArgs(StructureChangeType, Int32[]) Construtor
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
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 tempo de execução (ID) do elemento Automatização da Interface de Utilizador cuja estrutura mudou.
Exemplos
O exemplo seguinte mostra como construir e criar um evento quando crianças são adicionadas ou removidas de uma caixa de lista 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
Observações
Os valores que podem ser devolvidos em structureChangeType dependem da implementação do fornecedor Automatização da Interface de Utilizador. Por exemplo, quando itens são adicionados ou removidos de uma caixa de lista Win32, se o fornecedor não conseguir determinar o número de itens adicionados ou removidos, pode especificar ChildrenInvalidated e não ChildAdded ou ChildRemoved.
A tabela seguinte descreve a informação no evento recebida StructureChangedEventHandler pelo para diferentes alterações estruturais.
structureChangeType |
Origem do evento | runtimeId |
|---|---|---|
| ChildAdded | A criança que foi adicionada. | A criança que foi adicionada. |
| ChildRemoved | O progenitor da criança que foi removida. | A criança que foi retirada. |
| ChildrenBulkAdded | O progenitor das crianças que foram adicionadas. | O progenitor das crianças que foram adicionadas. |
| ChildrenBulkRemoved | O progenitor das crianças que foram removidas. | O progenitor das crianças que foram removidas. |
| ChildrenInvalidated | O progenitor das crianças que foram invalidadas. | O progenitor das crianças que foram invalidadas |
Controlos personalizados podem não conseguir fornecer um valor significativo em runtimeId. Para obter mais informações, veja RaiseStructureChangedEvent.