diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Automation/Peers/ItemAutomationPeer.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Automation/Peers/ItemAutomationPeer.cs index 184f9149ba2..ebc47e91afc 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Automation/Peers/ItemAutomationPeer.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Automation/Peers/ItemAutomationPeer.cs @@ -148,6 +148,22 @@ private bool IsItemInAutomationTree() } + /// + override internal bool IgnoreUpdatePeer() + { + // Ignore UpdatePeer if the we're no longer in the automation tree. + // There's no need to update such a peer, as it no longer + // participates in automation. And UpdatePeer actually throws exceptions + // in some cases. + + if (!IsItemInAutomationTree()) + { + return true; + } + + return base.IgnoreUpdatePeer(); + } + override internal bool IsDataItemAutomationPeer() { return true;