在我们的wpf应用程序中,我们正在构造窗口时添加事件,像这样:
AddHandler(Keyboard.KeyUpEvent, (KeyEventHandler)HandleKeyDownEvent);
this.Closing += new System.ComponentModel.CancelEventHandler(WindowF_Closing);
this.Loaded += new RoutedEventHandler(WindowF_Loaded);
在关闭事件中删除这些事件以使窗口被处理,这是个好主意吗?
RemoveHandler(Keyboard.KeyUpEvent, (KeyEventHandler)HandleKeyDownEvent);
this.Closing -= new System.ComponentModel.CancelEventHandler(WindowF_Closing);
this.Loaded -= new RoutedEventHandler(WindowF_Loaded);