Hello , my problem is the following :
I refresh data in a period of time , and when my data is refreshed i get this exception :
{System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at Telerik.Windows.Controls.Scheduling.HierarchicalGroupInfoAdapter.get_Item(GroupKey key)
at Telerik.Windows.Controls.GanttView.GanttGroupsDataSource.<GetGroupsForItem>b__0(GroupKey key)
at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
at Telerik.Windows.Controls.GanttView.RowHighlightingAndSelectionData.GetHierarchicalItemForEvent(Object e)
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at Telerik.Windows.Core.BatchObservableCollection`1.InsertMany(Int32 startIndex, IEnumerable`1 itemsToAdd)
at Telerik.Windows.Core.SynchronizedCollection`2.OnSourceCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)
at Telerik.Windows.Core.SelectionChanger`1.SynchronizeInternalSelection()
at Telerik.Windows.Core.SelectionChanger`1.End()
at Telerik.Windows.Controls.Scheduling.SchedulingSelector.OnItemsChanged(NotifyCollectionChangedAction action, IList newItems, IList oldItems)
at Telerik.Windows.Controls.Scheduling.SchedulingSelector.OnItemsCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
at Telerik.Windows.Core.BatchObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
at Telerik.Windows.Core.BatchObservableCollection`1.InsertMany(Int32 startIndex, IEnumerable`1 itemsToAdd)
at Telerik.Windows.Core.SynchronizedCollection`2.OnSourceCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
at Telerik.Windows.Core.HierarchicalCollectionAdapterBase.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
at Telerik.Windows.Core.HierarchicalCollectionAdapterBase.OnInsertItems(Int32 index, IList items)
at Telerik.Windows.Core.HierarchicalCollectionAdapterBase.OnItemsAddedToSourceCollection(Int32 startIndex, IEnumerable addedItems)
at Telerik.Windows.Core.HierarchicalCollectionAdapterBase.OnSourceCollectionChanged(NotifyCollectionChangedEventArgs e)
at Telerik.Windows.Core.CollectionChangedHelper.OnTargetCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)
at System.Collections.ObjectModel.Collection`1.Add(T item)
at WavePortal.Modules.SafetySupervision.ViewModels.SafetySupervisionViewModel.<>c__DisplayClass6.<_safetySupervisionProxy_GetAllPtwsCompleted>b__4()}
I have the problem only when the GanttView is visible , which menas that the problem is not in my collection.
I refresh the ItemsSource of the GanttView in this way :
Collection.Clear();
foreach ( ... )
{
Collection.Add(item);
}
I refresh data in a period of time , and when my data is refreshed i get this exception :
{System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at Telerik.Windows.Controls.Scheduling.HierarchicalGroupInfoAdapter.get_Item(GroupKey key)
at Telerik.Windows.Controls.GanttView.GanttGroupsDataSource.<GetGroupsForItem>b__0(GroupKey key)
at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
at Telerik.Windows.Controls.GanttView.RowHighlightingAndSelectionData.GetHierarchicalItemForEvent(Object e)
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at Telerik.Windows.Core.BatchObservableCollection`1.InsertMany(Int32 startIndex, IEnumerable`1 itemsToAdd)
at Telerik.Windows.Core.SynchronizedCollection`2.OnSourceCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)
at Telerik.Windows.Core.SelectionChanger`1.SynchronizeInternalSelection()
at Telerik.Windows.Core.SelectionChanger`1.End()
at Telerik.Windows.Controls.Scheduling.SchedulingSelector.OnItemsChanged(NotifyCollectionChangedAction action, IList newItems, IList oldItems)
at Telerik.Windows.Controls.Scheduling.SchedulingSelector.OnItemsCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
at Telerik.Windows.Core.BatchObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
at Telerik.Windows.Core.BatchObservableCollection`1.InsertMany(Int32 startIndex, IEnumerable`1 itemsToAdd)
at Telerik.Windows.Core.SynchronizedCollection`2.OnSourceCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
at Telerik.Windows.Core.HierarchicalCollectionAdapterBase.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
at Telerik.Windows.Core.HierarchicalCollectionAdapterBase.OnInsertItems(Int32 index, IList items)
at Telerik.Windows.Core.HierarchicalCollectionAdapterBase.OnItemsAddedToSourceCollection(Int32 startIndex, IEnumerable addedItems)
at Telerik.Windows.Core.HierarchicalCollectionAdapterBase.OnSourceCollectionChanged(NotifyCollectionChangedEventArgs e)
at Telerik.Windows.Core.CollectionChangedHelper.OnTargetCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)
at System.Collections.ObjectModel.Collection`1.Add(T item)
at WavePortal.Modules.SafetySupervision.ViewModels.SafetySupervisionViewModel.<>c__DisplayClass6.<_safetySupervisionProxy_GetAllPtwsCompleted>b__4()}
I have the problem only when the GanttView is visible , which menas that the problem is not in my collection.
I refresh the ItemsSource of the GanttView in this way :
Collection.Clear();
foreach ( ... )
{
Collection.Add(item);
}