I am receiving an error message
"Recursive call to Automation Peer API is not valid"
When loading a
datagrid
with adatatemplatecolumn
containing acombobox
column. The error ends up caught in our unhandled exception code. This seems to be an issue on my machine, and google has provided no source of guidance on resolving the issue. The issue appears to only occur when I am populating thecomboboxes
with data.Populating the comboboxes (if I do not load data) works correctly, and while the error is displayed I am able to see the data properly retrieved in the background.
I am using a
WPF datagrid
where I'm using aDataGridTemplateColumn
for adding acombobox
inside thegrid
. I have the drop down list bound to anenum
using anobjectdataprovider
.In the code behind when initializing my screen I use a
Linq2Sql
statement to retrieve data and populate theItemssource
of the grid.
<grid:DataGrid.Resources>
<ObjectDataProvider
x:Key="ChangeTypeData"
MethodName="GetValues"
ObjectType="{x:Type System:Enum}">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="namespace:ChangeType" />
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
</grid:DataGrid.Resources>
<grid:DataGrid.Columns>
<grid:DataGridTextColumn Binding="{Binding DatapointName}" Header="Datapoint Changed" IsReadOnly="True" Width="Auto" />
<grid:DataGridTemplateColumn Header="Change Type">
<grid:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox
Text="{Binding Path=ChangeTypeName}"
ItemsSource="{Binding Source={StaticResource ChangeTypeData}}"
Name="dgcboChangeType"
SelectionChanged="dgcboChangeType_SelectionChanged"/>
</DataTemplate>
</grid:DataGridTemplateColumn.CellTemplate>
</grid:DataGridTemplateColumn>
<grid:DataGrid.Columns>
Any and all guidance on solving this issue is appreciated.