WPF为自动化同级API递归调用无效 [英] WPF Recursive call to Automation Peer API is not valid

查看:836
本文介绍了WPF为自动化同级API递归调用无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到一条错误信息,以自动化同级API递归调用无效加载含有组合框列datatemplatecolumn一个DataGrid时。错误最终陷入了未处理的异常code。这似乎是我的机器上的一个问题,而谷歌没有提供指导的来源解决这个问题。这个问题似乎是,当我用数据填充组合框只发生。填充组合框(如果我没有加载数据)正常运行,并且在显示错误,我能看到在后台正确检索到的数据。

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 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 the comboboxes 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.

我使用,我正在使用DataGridTemplateColumn添加的网格内的组合框一个WPF数据网格。我有下拉必然要使用ObjectDataProvider的一个枚举列表。在初始化我的屏幕时,后面的code我使用LINQ2SQL语句来检索数据和填充网格的ItemsSource。

I am using a WPF datagrid where I'm using a DataGridTemplateColumn for adding a combobox inside the grid. I have the drop down list bound to an enum using an objectdataprovider. In the code behind when initializing my screen I use a Linq2Sql statement to retrieve data and populate the Itemssource 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>


这是解决这一问题的任何及所有指导AP preciated。

Any and all guidance on solving this issue is appreciated.

推荐答案

我已经通过在网格控件关闭自动绕过在我结束的问题。我发现这个问题是独一无二的WPF工具包的控制,但我是有过渡到4.0正式发布DataGrid的问题(无关了这个问题。)

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.)

所以,相反,我得到来自WPFToolkit类提供此覆盖:

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.

这篇关于WPF为自动化同级API递归调用无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆