From f2d5892dee1f37b3f963aa21a10d39111fda9f37 Mon Sep 17 00:00:00 2001 From: Sam Bent Date: Tue, 3 Aug 2021 12:05:08 -0700 Subject: [PATCH] Port UpdatePeer fix from 4.8 --- .../Automation/Peers/ItemAutomationPeer.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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;