我有这样的 WPF 表单代码(C#):
private void formSearch_Loaded(object sender, RoutedEventArgs e)
{
Publisher.dataUpdated += search;
}
private void formSearch_Unloaded(object sender, RoutedEventArgs e)
{
Publisher.dataUpdated -= search;
}
当我打开或将选项卡更改为此表单时,formSearch_Loaded
每当我转到此选项卡/表单时都会运行,但是当我更改到另一个选项卡formSearch_Unloaded
时会自动运行(基本上在 MDIstyle = "MDI" 而不是 MDIstyle = "tabbed"formSearch_Unloaded
将运行当表格关闭时)。
关闭选项卡时如何运行此formSearch_Unloaded
事件(例如我使用mdistyle =“ mdi”)而不是更改tab?