views:

921

answers:

1

I am using the PagedCollectionView for grouping. I have a DataGrid and a textbox with a search button. The ItemSource of the grid is my PagedCollectionView, and the PagedCollectionView wraps an ObservableCollection because items in the grid can have their bound objects updated by a background process. When you click search, I first clear by ObservableCollection then load it with data from a db. The moment I call clear on my collection, the contents on of the DataGrid disappear, INCLUDING THE COLUMNS. They reappear when items are added to my collection. I would really like the columns and their headers to remain, as when they disappear it is quite jarring, not to mention sort orders, etc are lost. I believe the items disappear instantaneously because it is an ObservableCollection, but I need it to be so that the rows can be updated by the aforementioned background process. If I remove the PagedCollectionView as a wrapper and simply set the ItemSource of the DataGrid to the ObservableCollection, none of this behavior occurs, my columns and headers persist even when the collection is cleared, and my rows update instantaneously by the background process. Has anyone else observed this behavior? Does anyone know any workarounds? Or am I just doing something wrong?

A: 

The problem occurred because I was using AutoGenerated columns. Everytime I cleared my collection the PageCollectionView regenerated the columns for me. By turning that property off and using Blend to "pre-generate" the columns for me, I was able to get around the issue.

Hydroslide