Telerik blogs

I’ve made small example to illustrate how to use NotifyCollectionChangedAction.Replace in order to provide very fast real-time data update with RadGridView for Silverlight and WPF. 
image

 

While Binding in both Silverlight and WPF will react immediately to any property change of INotifyPropertyChanged object and will update RadGridView cell values sometimes it is important to refresh the grid in order to update a sorting, filtering, grouping, etc. after some value change. To achieve your goal in such situation you have two options:

 

- listen for PropertyChanged of every item in the collection and raise NotifyCollectionChangedAction.Reset for the collection in order to tell the UI components to refresh themselves

- replace an item in the collection with new instance with updated values

 

The first approach can be extremely inefficient (everything in the UI component will be regenerated from scratch) and may lead to serious performance problems (and even memory leaks if not implemented properly), the second approach however will provide superior performance if the UI element can handle properly Replace action.

 

In RadGridView for Silverlight/WPF you can use NotifyCollectionChangedAction.Replace without any problems and your sorting, filtering, grouping, etc. will be re-executed correctly very fast.
To check this for yourself you can download my sample application where the grid is updated on every millisecond with some random “stock data” plus I’ve applied also CellStyleSelector in order to colorize the second column cells conditionally.

 

Enjoy!

 


About the Author

Vladimir Enchev

is Director of Engineering, Native Mobile UI & Frameworks

Comments

Comments are disabled in preview mode.