Sdílet prostřednictvím


StructureChangedEventArgs(StructureChangeType, Int32[]) Konstruktor

Definice

Inicializuje novou instanci StructureChangeType třídy, určuje typ změny a identifikátor (ID) prvku, jehož struktura se změnila.

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

Jedna hodnota, která určuje typ změny.

runtimeId
Int32[]

Identifikátor modulu runtime (ID) prvku model UI Automation, jehož struktura se změnila.

Příklady

Následující příklad ukazuje, jak vytvořit a vyvolat událost při přidání podřízených položek nebo odebrání z vlastního seznamu.

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

Poznámky

Hodnoty, které lze vrátit, structureChangeType závisí na implementaci poskytovatele model UI Automation. Pokud se například položky přidají do seznamu Win32 nebo se z něj odeberou, může určit počet přidaných nebo odebraných položek, může určit ChildrenInvalidated , a ne ChildAdded nebo ChildRemoved.

Následující tabulka popisuje informace v události přijaté pro StructureChangedEventHandler různé změny struktury.

structureChangeType Zdroj událostí runtimeId
ChildAdded Dítě, které bylo přidáno. Dítě, které bylo přidáno.
ChildRemoved Nadřazený objekt podřízeného objektu, který byl odebrán. Dítě, které bylo odebráno.
ChildrenBulkAdded Nadřazený objekt podřízených položek, které byly přidány. Nadřazený objekt podřízených položek, které byly přidány.
ChildrenBulkRemoved Nadřazený objekt podřízených položek, které byly odebrány. Nadřazený objekt podřízených položek, které byly odebrány.
ChildrenInvalidated Nadřazený objekt podřízených položek, které byly zneplatněny. Nadřazený objekt podřízených položek, které byly zneplatněny

Vlastní ovládací prvky nemusí být schopny poskytnout smysluplnou hodnotu v runtimeId. Další informace naleznete v tématu RaiseStructureChangedEvent.

Platí pro

Viz také