Hi,
Our FlatDataSource's ItemsSource is set to an ICollectionView which wraps an ObservableCollection. The items in the collection do implement INotifyPropertyChanged.
Does the grid data refresh automatically when new items are added/removed to the collection and when they fire the PropertyChanged event?
If not - what's the best way to handle this? Calling FlatDataSource.RefreshGrid whenever the collection is changed doesn't seem optimal.
We'd like to have a couple of editable columns. If RefreshGrid is called while the we're editing those columns, their value is reset before we're finished.
Thanks.
I think I have found some way to set ICollectionView for ItemsSource and it to be updated automatically when add/remove items. It works with XamPivotGrid and other controls like listbox. May be you are missing something in your implementation of ICollectionView just like me. In this project you can search for this line of code: this.ItemsSource = CollectionViewSource.GetDefaultView(collection.Items); This is what makes the difference.
Thanks,
M.Yovchev
I think that Refresh() method should be called when you have ICollectionView for DataSource ItemsSource or subscribe the ICollectionView items to collection changed event. Does your implementation work with other control like listbox? If so can you please share it.
If DataSource ItemsSource is an ObservableCollection then add/remove will be affected automatically in XamPivotGrid.
If you want to change NumberOfUnits property or other property you should call also RefreshGrid() method to the datadource nevermind what is the type of the DataSource ItemsSource - ICollectionView or ObservableCollection. Also changing property to object that is in ICollectionView will not refresh automatically, because this collection is not monitoring such changes.
I can see it's working because you manually call the SalesCollection.Refresh() method. I was expecting the XamPivotGrid to reflect the changes upon adding items to the ObservableCollection.
BTW if you wanted to update the Sale's NumberOfUnits property and had the Pivot Grid reflect the changes - how would you do it?
I have created a simple project that fits the scenario described above. XamPivotGrid refreshes automatically when new item is added/removed.