我们使用WPF Tookit DataGrid和.NET 3.5大约2年.我们有两个抛出异常的情况 - "对Automation Peer API的递归调用无效".它退出了奇怪和古怪,很少有PC有这样的问题.
案例一:
下拉式combox(WPF Tookit DataGrid作为DropDown内容控件):
它可以通过以下方式解决:
protected override AutomationPeer OnCreateAutomationPeer()
{
return null;
}
Run Code Online (Sandbox Code Playgroud)
此解决方案来自WPF Recursive调用Automation Peer API无效.
案例二:
WPF Tookit DataGrid有一个Temlate列,单元格模板有一个下拉式combox(WPF Tookit DataGrid作为DropDown内容控件).它不能通过上述解决方案来解决.
*Exception Stack:
Exception object: 0ac4e048
Exception type: System.InvalidOperationException
Message: Recursive call to Automation Peer API is not valid.
InnerException: <none>
StackTrace (generated):
SP IP Function
0036E3A4 61A0CEFE PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.GetChildren()+0x366bde
0036E3D4 616A5C34 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(System.Windows.Automation.Peers.AutomationPeer)+0x18
0036E3EC 616A5C73 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(System.Windows.Automation.Peers.AutomationPeer)+0x57
0036E404 616A5C73 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(System.Windows.Automation.Peers.AutomationPeer)+0x57
0036E41C 616A5C73 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(System.Windows.Automation.Peers.AutomationPeer)+0x57
0036E434 616A5C73 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(System.Windows.Automation.Peers.AutomationPeer)+0x57
0036E44C 616A5C73 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(System.Windows.Automation.Peers.AutomationPeer)+0x57 …Run Code Online (Sandbox Code Playgroud)