I am trying to add tabitems to tabcontrol at run time ,
tabcontrol.Items.Add(item);
it works fine but eventually , I got the following exceptions after adding\removing tabitems
Value does not fall within the expected range.
Inner Exception Message:
Exception Stack Trace: at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
at MS.Internal.XcpImports.Collection_InsertValue[T](PresentationFrameworkCollection`1 collection, UInt32 index, CValue value)
at MS.Internal.XcpImports.Collection_InsertDependencyObject[T](PresentationFrameworkCollection`1 collection, UInt32 index, DependencyObject value)
at System.Windows.PresentationFrameworkCollection`1.InsertDependencyObject(Int32 index, DependencyObject value)
at System.Windows.Controls.UIElementCollection.InsertInternal(Int32 index, UIElement value)
at System.Windows.Controls.TabControl.InsertIntoTabPanel(Int32 index, TabItem tabItem)
at System.Windows.Controls.TabControl.OnItemsChanged(NotifyCollectionChangedEventArgs e)
at System.Windows.Controls.ItemsControl.OnItemCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
at System.Windows.Controls.ItemCollection.NotifyCollectionChanged(NotifyCollectionChangedEventArgs e)
at System.Windows.Controls.ItemCollection.AddImpl(Object value)
at System.Windows.Controls.ItemCollection.AddInternal(Object value)
Comments: ** Comment from web user: bolanki **
tabcontrol.Items.Add(item);
it works fine but eventually , I got the following exceptions after adding\removing tabitems
Value does not fall within the expected range.
Inner Exception Message:
Exception Stack Trace: at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
at MS.Internal.XcpImports.Collection_InsertValue[T](PresentationFrameworkCollection`1 collection, UInt32 index, CValue value)
at MS.Internal.XcpImports.Collection_InsertDependencyObject[T](PresentationFrameworkCollection`1 collection, UInt32 index, DependencyObject value)
at System.Windows.PresentationFrameworkCollection`1.InsertDependencyObject(Int32 index, DependencyObject value)
at System.Windows.Controls.UIElementCollection.InsertInternal(Int32 index, UIElement value)
at System.Windows.Controls.TabControl.InsertIntoTabPanel(Int32 index, TabItem tabItem)
at System.Windows.Controls.TabControl.OnItemsChanged(NotifyCollectionChangedEventArgs e)
at System.Windows.Controls.ItemsControl.OnItemCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
at System.Windows.Controls.ItemCollection.NotifyCollectionChanged(NotifyCollectionChangedEventArgs e)
at System.Windows.Controls.ItemCollection.AddImpl(Object value)
at System.Windows.Controls.ItemCollection.AddInternal(Object value)
Comments: ** Comment from web user: bolanki **
I am also having the same issue... is there a resolution or workaround?