From f4f478c910ca1bda40f9b8ef29b2038854896340 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Thu, 28 Oct 2021 14:50:50 +0200 Subject: [PATCH] Move ChildrenChanged to AutomationPeer. --- .../Automation/Peers/AutomationPeer.cs | 13 +++++++++++++ .../Automation/Peers/ControlAutomationPeer.cs | 4 +--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/Avalonia.Controls/Automation/Peers/AutomationPeer.cs b/src/Avalonia.Controls/Automation/Peers/AutomationPeer.cs index fbca22031a..54b2fcc7fa 100644 --- a/src/Avalonia.Controls/Automation/Peers/AutomationPeer.cs +++ b/src/Avalonia.Controls/Automation/Peers/AutomationPeer.cs @@ -167,8 +167,21 @@ namespace Avalonia.Automation.Peers /// The provider, or null if not implemented on this peer. public T? GetProvider() => (T?)GetProviderCore(typeof(T)); + /// + /// Occurs when the children of the automation peer have changed. + /// + public event EventHandler? ChildrenChanged; + + /// + /// Occurs when a property value of the automation peer has changed. + /// public event EventHandler? PropertyChanged; + /// + /// Raises an event to notify the automation client the the children of the peer have changed. + /// + protected void RaiseChildrenChangedEvent() => ChildrenChanged?.Invoke(this, EventArgs.Empty); + /// /// Raises an event to notify the automation client of a changed property value. /// diff --git a/src/Avalonia.Controls/Automation/Peers/ControlAutomationPeer.cs b/src/Avalonia.Controls/Automation/Peers/ControlAutomationPeer.cs index 3cbcdcf348..f7a993e16b 100644 --- a/src/Avalonia.Controls/Automation/Peers/ControlAutomationPeer.cs +++ b/src/Avalonia.Controls/Automation/Peers/ControlAutomationPeer.cs @@ -26,8 +26,6 @@ namespace Avalonia.Automation.Peers public Control Owner { get; } - public event EventHandler? ChildrenChanged; - public AutomationPeer GetOrCreate(Control element) { if (element == Owner) @@ -110,7 +108,7 @@ namespace Avalonia.Automation.Peers protected void InvalidateChildren() { _childrenValid = false; - ChildrenChanged?.Invoke(this, EventArgs.Empty); + RaiseChildrenChangedEvent(); } ///