I have a data grid with the Data Source being set to an ObservableCollection. I have a few checkboxes next to my grid. Clicking on these will add or remove contents to/from the ObservableCollection, and in turn, the grid. My grid is sized so that only about 8 records display; user can scroll if there's more than 8. If the scrollbar appears (> 8 items) and I click on a checkbox which calls the Add/Remove method on the observable collection, I get the error:
If I manually scroll down (all the way) or sort the items in the grid, this error does not occur. Stranger even, this error only occurs when I run my app in Vista.
{"Index was out of range. Must be non-negative and less than the size of the collection.\r\nParameter name: index"}
at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
at System.ThrowHelper.ThrowArgumentOutOfRangeException()
at System.Collections.Generic.List`1.get_Item(Int32 index)
at System.Collections.ObjectModel.Collection`1.System.Collections.IList.get_Item(Int32 index)
at Infragistics.Windows.DataPresenter.DataRecordCollection.AllocateNewRecord(Int32 index)
at gh.a(Int32 A_0, Boolean A_1, Boolean A_2, Boolean& A_3)
at dk.a(SparseArray A_0, Int32 A_1)
at Infragistics.Windows.Helpers.SparseArray.a(ICreateItemCallback A_0, c A_1, Int32 A_2, Int32 A_3)
at Infragistics.Windows.Helpers.SparseArray.GetItemAtVisibleIndex(Int32 visibleIndex, ICreateItemCallback createItemCallback)
at dk.b(Int32 A_0)
at Infragistics.Windows.DataPresenter.ViewableRecordCollection.c(Int32 A_0)
at Infragistics.Windows.DataPresenter.ViewableRecordCollection.System.Collections.IList.get_Item(Int32 index)
at System.Windows.Data.ListCollectionView.GetItemAt(Int32 index)
at System.Windows.Controls.ItemCollection.GetItemAt(Int32 index)
at System.Windows.Controls.ItemCollection.get_Item(Int32 index)
at Infragistics.Windows.Virtualization.RecyclingItemContainerGenerator.a.a(Boolean A_0, Boolean& A_1)
at Infragistics.Windows.Virtualization.RecyclingItemContainerGenerator.GenerateNext(Boolean& isNewlyRealized)
at Infragistics.Windows.DataPresenter.GridViewPanel.a(Size A_0, Boolean A_1, Boolean A_2, Int32 A_3, FieldLayout& A_4, Int32& A_5, Int32& A_6)
at Infragistics.Windows.DataPresenter.GridViewPanel.MeasureOverride(Size availableSize)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
...
Sounds like a bug. In the meantime, is there anyway I can programmatically force a proper "reload" of the data? In the same vein, if I scroll all the way down and remove elements from the collection, the result can look quite weird. The drig is scrolled all the way to the bottom, and only one item appears on the top (but there's really 6 items).How can I force a redraw?
Hi srozga,
As you point out, this sounds like a bug. You may want to report this issue at http://es.infragistics.com/gethelp. If you do so please include a sample that reproduces this issue. That will help us track it down.
As for a way to reload data, try setting DataSource property to null and then back to the data source. This may or may not be desirable for you as you may loose settings, if any, on individual records and cells.
Sandip
Hi
You may want to try applying the 7.1 or 7.2 hotfis (depending what version you're running) but you won't have easy access to it if you're an evaluation user (you'[d need to contact support and state your case and see if they'll give t to you).
I had issues when trying to prgramatically force a data refresh - in the end I created a new binding object with nothing set and set the binging of the xamDataGrid to it. Then renew the binding object (or create another binding object) with properties set and then apply it again to the xamDataGrid.
The above said, I am an eval user so hotfixed customers may offer a different solution.
Regards
Paul