I am receiving an error message \"Recursive call to Automation Peer API is not valid\" when loading a datagrid with a datatemplatecolumn containing a combobox column. The er
I was getting the same problem in NET 3.5 with WPFToolkit DataGrid.
I have bound my WPFToolkit DataGrid to EntityFramework ObservableCollection, with hierarchy of entities that have two way associations (Parent<->Items).
I solved the issue by disabling implicitly enabled AutoGenerateColumns on the DataGrid, and manually setting the columns.
Hope this helps.
I've bypassed the problem on my end by turning off Automation on the grid control. I found that the problem was unique to the WPF Toolkit control, but I was having problems transitioning to the 4.0 official release DataGrid (unrelated to this question.)
So instead, I derive the class from the WPFToolkit and supply this override:
protected override AutomationPeer OnCreateAutomationPeer()
{
return null;
}
Maybe someone can tell us if this is a good idea or not.
I also had the same problem. So I checked also the reference to the WPFToolkit. I had two same versions of WPFToolkit installed (Version v3.5.50211.1), but only on my Laptop works it fine.
So I put the older version v3.5.40619.1 on my Windows Embedded Standard 7 PC and no more exceptions.
So I came to the conclusion that in some cases the newer Version has some problems with the runing system.
I had exactly the same error. However for me it was strange that the same application was working fine on my laptop and caused the error on my desktop PC. The same OS, the same architecture and the same Visual Studio with the same add-ons.
So I checked references to WPFToolkit on my laptop, where everything was fine. It pointed to:
C:\Program Files (x86)\WPF Toolkit\v3.5.40619.1\WPFToolkit.dll
then I checked reference on my desktop, it pointed to:
C:\Program Files (x86)\WPF Toolkit\v3.5.50211.1\WPFToolkit.dll
As you can see I had two different versions of WPFToolkit installed. I copied whole folder from my laptop to my desktop, changed references from version v3.5.50211.1 to v3.5.40619.1 and the problem was resolved. No more exceptions. Hope this will help someone as well.
Hi I also had same problem when I am running Microsoft Test Manager with our WPF application. We were using the WPFtoolkit version v3.5.50211.1, replacing WPF toolkit with lower version v3.5.40619.1 has solved this problem.
Now we are able to run the MTM tool and WPF application both simultaneously.
In WPFToolkit v3.5.50211.1 one bug is fixed related to UI Automation and I guess because of that this automation peer issue is coming while using the latest WPFtoolkit.
I was able to fix this issue by replacing both the DataGrid and the ComboBox in the WPF XAML file with the following two derived classes which both override the OnCreateAutomationPeer() method.
public class SafeDataGrid : DataGrid
{
protected override AutomationPeer OnCreateAutomationPeer()
{
return null;
}
}
public class SafeComboBox : ComboBox
{
protected override AutomationPeer OnCreateAutomationPeer()
{
return null;
}
}