WPF Recursive call to Automation Peer API is not valid

后端 未结 8 854
孤独总比滥情好
孤独总比滥情好 2020-12-06 15:56

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

8条回答
  •  攒了一身酷
    2020-12-06 16:45

    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;
        }
    }
    

提交回复
热议问题