Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

One way to update an ObservableCollection in WPF without refreshing the entire page is to use data binding.

To do this, you would first bind the ObservableCollection to a UI element, such as a ListView or DataGrid. Then, when you want to update the collection, you would simply add, remove, or modify items in the collection itself. The UI element should automatically reflect these changes, without requiring the entire page to be refreshed.

For example, if you have a DataGrid bound to an ObservableCollection of customer objects, you could add a new customer by simply calling the Add method on the collection. The DataGrid should automatically update to show the new customer, without requiring any manual refresh.

Alternatively, you could use the INotifyPropertyChanged or INotifyCollectionChanged interfaces to explicitly notify the UI when the collection has been updated. However, this may require more code and may not be necessary if you are already using data binding.