Update a Data Source Collection (Compact 7)
3/12/2014
You can update the items in a data source collection. For example, if a user adds or deletes media files in a playlist and then reloads the playlist on a device, the media application can update the collection.
To update a data source collection
In Platform Builder, open your OS design project.
In your subproject, open the source code file where you want to add functionality for updating the data source collection. For example, in Solution Explorer, browse to Subprojects\<Subproject Name>\Source files, and open MainPage.cpp.
To block other threads from accessing the collection object, implement a thread safety mechanism. For example, create an XRAutoCriticalSection object and call EnterCriticalSection.
Obtain a pointer to the XRObservableCollection<ItemType> collection. For example, call the derived method IXRItemsControl::GetItemsSource.
Update the data source collection by doing the following:
To add a new item, call the derived method XRValueCollectionT.Add(const ItemType&).
To remove an item, call the derived method XRValueCollectionT.Remove(const ItemType&).
To replace an item, call the derived method XRValueCollectionT.SetItem(int,const ItemType&).
To raise the CollectionChanged event, call XRObservableCollection.OnCollectionChanged(XRCollectionChangedCustomEventArgs *).
Release ownership of the thread. For example, call LeaveCriticalSection.