M
MahmudX
Guest
Hi!
I have two `ObservableCollection<T>` and its bonded with two different `ListView` UI.
ObservableCollection<Department> deptList = new ObservableCollection<Department>();
ObservableCollection<Teacher> teacherList = new ObservableCollection<Teacher>();
User can add or remove items from the collection in the run time.
At some point, if either of the lists is empty, the app freezes and throws an unhandled exception.
#if DEBUG && !DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
UnhandledException += (sender, e) =>
{
if (global::System.Diagnostics.Debugger.IsAttached) global::System.Diagnostics.Debugger.Break();
};
#endif
Point to be noted, `Teacher` class derives from `Department` class. And if I remove a Department, all the teacher associated with that department gets removed too.
To prevent crashing the app, I had to add a hardcoded garbage item to the list which the user can remove later in run time. And again if one of the lists is empty, the app crashes. But if there is at least one item in both lists, nothing happens.
Now, my question is How can I resolve this issue without adding any type of garbage item? I want to prevent crashing even if the lists are empty or null.
Continue reading...
I have two `ObservableCollection<T>` and its bonded with two different `ListView` UI.
ObservableCollection<Department> deptList = new ObservableCollection<Department>();
ObservableCollection<Teacher> teacherList = new ObservableCollection<Teacher>();
User can add or remove items from the collection in the run time.
At some point, if either of the lists is empty, the app freezes and throws an unhandled exception.
#if DEBUG && !DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
UnhandledException += (sender, e) =>
{
if (global::System.Diagnostics.Debugger.IsAttached) global::System.Diagnostics.Debugger.Break();
};
#endif
Point to be noted, `Teacher` class derives from `Department` class. And if I remove a Department, all the teacher associated with that department gets removed too.
To prevent crashing the app, I had to add a hardcoded garbage item to the list which the user can remove later in run time. And again if one of the lists is empty, the app crashes. But if there is at least one item in both lists, nothing happens.
Now, my question is How can I resolve this issue without adding any type of garbage item? I want to prevent crashing even if the lists are empty or null.
Continue reading...