WPF:Automation.Peers.ItemAutomationPeer.GetNameCore上的NullReferenceException

WPF:Automation.Peers.ItemAutomationPeer.GetNameCore上的NullReferenceException,wpf,automation,nullreferenceexception,Wpf,Automation,Nullreferenceexception,我有一个烦恼的问题,花了一整天的时间来解决它,但仍然无法解决它。 我在WPF UI上有一个按钮,用于向treeview添加项目,xaml中的代码如下: <Button Content="Create Item" Command="{Binding NewItem}" Click="NewItemButton_Click"

我有一个烦恼的问题,花了一整天的时间来解决它,但仍然无法解决它。 我在WPF UI上有一个按钮,用于向treeview添加项目,xaml中的代码如下:

<Button Content="Create Item"  
                                        Command="{Binding NewItem}"
                                        Click="NewItemButton_Click"
                                        TabIndex="16"                                                                                           
                                        ToolTip="{Binding NewItemHelpText}"
                                        ToolTipService.ShowOnDisabled="True">
                                        <Button.IsEnabled>
                                            <MultiBinding Converter="{StaticResource LogicalAndConverter}">
                                                <Binding Path="CurrentItem" Converter="{StaticResource ItemCreationConverter}"/>
                                                <Binding Path="ControlMode" Converter="{StaticResource MyConverter}" ConverterParameter="{x:Static local:Option.ReadOnly}"/>
                                            </MultiBinding>
                                        </Button.IsEnabled>
                                    </Button>
这个异常是随机抛出的,在添加一些日志来调试代码之后,我发现NewItemButton\u Click事件和NewItem命令都执行到了最后,我搜索了我的工作解决方案,没有找到任何关于自动化的信息,我不知道这个异常抛出的原因和地点

有人能帮我吗?谢谢

> ERROR MyApplication.App [(null)] - Error in MyApplication
   System.NullReferenceException: Object reference not set to an instance of an object.
   at System.Windows.Automation.Peers.ItemAutomationPeer.GetNameCore()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdatePeer(Object arg)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)