…probably I did not read the question properly in first place, down-voted for a reason. Here is the answer:
public partial class MyWindow : Window {
protected override void OnClosing(System.ComponentModel.CancelEventArgs e) {
base.OnClosing(e);
}
protected override void OnClosed(EventArgs e) {
base.OnClosed(e);
}
Alternatively, this is the event-based approach (which is not really needed because Window is sub-classed anyway:
MyWindow.Closed += (sender, eventArgs) => {
};
MyWindow.Closing += (sender, eventArgs) => {
};
Both ways are much better than the code auto-generated by the Designer. It's funny that the code not based on anonymous methods is still used. It is less supportable but probably easier of generation (or code generation uses legacy code, which is explainable). Anonymous-based way is shorter and helps supportability, because writing a method with exact signature and writing type names is not required. Additionally, in lambda form the types of arguments are inferred from event type.
—SA