I have a WPF form code like this (C #):
private void formSearch_Loaded(object sender, RoutedEventArgs e) { Publisher.dataUpdated += search; } private void formSearch_Unloaded(object sender, RoutedEventArgs e) { Publisher.dataUpdated -= search; }
When I open or change a tab in this form, formSearch_Loaded will run whenever I go to this tab / form, but when I go to another tab formSearch_Unloaded will start automatically (mainly in MDIstyle = "MDI" instead of MDIstyle = "tabbed " formSearch_Unloaded will work when the form is closed).
How can I fire this formSearch_Unloaded event when the tab is closed (for example, when I used MDIStyle = "MDI") instead of changing the page?
source share