StructureChangedEventArgs(StructureChangeType, Int32[]) Constructor
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Inicializa una nueva instancia de la StructureChangeType clase , especificando el tipo de cambio y el identificador (ID) del elemento cuya estructura cambió.
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
Valor único que especifica el tipo de cambio.
- runtimeId
- Int32[]
Identificador en tiempo de ejecución (ID) del elemento Automatización de la interfaz de usuario cuya estructura cambió.
Ejemplos
En el ejemplo siguiente se muestra cómo construir y generar un evento cuando se agregan o quitan elementos secundarios de un cuadro de lista personalizado.
/// <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
Comentarios
Los valores que se pueden devolver en structureChangeType dependen de la implementación del proveedor de Automatización de la interfaz de usuario. Por ejemplo, cuando se agregan o quitan elementos de un cuadro de lista Win32, si el proveedor no puede determinar el número de elementos agregados o quitados, puede especificar ChildrenInvalidated y no ChildAdded o ChildRemoved.
En la tabla siguiente se describe la información del evento recibido por StructureChangedEventHandler para los distintos cambios de estructura.
structureChangeType |
Origen del evento | runtimeId |
|---|---|---|
| ChildAdded | Elemento secundario que se agregó. | Elemento secundario que se agregó. |
| ChildRemoved | Elemento primario del elemento secundario que se quitó. | Elemento secundario que se quitó. |
| ChildrenBulkAdded | Elemento primario de los elementos secundarios que se agregaron. | Elemento primario de los elementos secundarios que se agregaron. |
| ChildrenBulkRemoved | Elemento primario de los elementos secundarios que se quitaron. | Elemento primario de los elementos secundarios que se quitaron. |
| ChildrenInvalidated | Elemento primario de los elementos secundarios que se invalidaron. | Elemento primario de los elementos secundarios que se invalidaron |
Es posible que los controles personalizados no puedan proporcionar un valor significativo en runtimeId. Para obtener más información, consulte RaiseStructureChangedEvent.