尝试从tabitems集合中删除项目时出现异常。 [英] Exception while trying to remove the items from the tabitems collection.

查看:70
本文介绍了尝试从tabitems集合中删除项目时出现异常。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





当我尝试从tabcontrol中删除tabitem时,我收到以下错误。



此时无法修改此节点的逻辑子节点,因为正在进行树步行。请找到下面的堆栈跟踪。



在System.Windows.FrameworkElement.RemoveLogicalChild(对象子)

在MS.Internal.Controls。 InnerItemCollectionView.ClearModelParent(Object item)

at MS.Internal.Controls.InnerItemCollectionView._RemoveAt(Int32 index,Int32 indexR,Object item)

at MS.Internal.Controls。 System.Windows.Controls.ItemCollection.RemoveAt(Int32 removeIndex)

Hi,

I am getting the below error when I am trying the remove the tabitem from tabcontrol.

Cannot modify the logical children for this node at this time because a tree walk is in progress. Please find the below stack trace.

at System.Windows.FrameworkElement.RemoveLogicalChild(Object child)
at MS.Internal.Controls.InnerItemCollectionView.ClearModelParent(Object item)
at MS.Internal.Controls.InnerItemCollectionView._RemoveAt(Int32 index, Int32 indexR, Object item)
at MS.Internal.Controls.InnerItemCollectionView.RemoveAt(Int32 index)
at System.Windows.Controls.ItemCollection.RemoveAt(Int32 removeIndex)

推荐答案

fishboneControl.Remove( PersonPage);



fishboneControl.Remove(PersonPage);

public void Remove(FishbonePage page)
       {
           for (var i = 0; i < Items.Count; ++i)
           {
               var currentPage = GetFishbonePage(Items[i], i);
               if (currentPage == null || !ReferenceEquals(currentPage, page))
               {
                   continue;
               }

               Items.RemoveAt(i);
           }

           EnsureChildPages();
       }


这篇关于尝试从tabitems集合中删除项目时出现异常。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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