I am using C#.
My grid sorts itself frequently based on the underlying data, which changes often. This is great. However, when the ObservableCollection size is modified (by adding or removing an object) while the sorting is taking place, I get a fatal error: "Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index"
Naturally, I expect any iteration to break when its collection is changed mid-loop. But I need to prevent this occurrence from crashing my app. Please help me understand why this exception is not being caught by the following code:
ExceptionManager.ExceptionCatched += ExceptionManager_ExceptionCatched; // Per Syncfusion's recommendation, I wire this handler before initializing the component to be sure it catches all possible exceptions.
InitializeComponent();
private void ExceptionManager_ExceptionCatched(object sender, ExceptionCatchedEventArgs e)
{
// log the exception here and keep going
}
Ideally when a Sort operation breaks, the app would just refresh the view and continue functioning normally. How can I achieve this?
Thank you!