1.使用SessionEnding事件参考MSDN。2.在需要处理 关机事件中可以注册SessionEnding事件
App.Current.SessionEnding += Current_SessionEnding;
private void Current_SessionEnding(object sender, SessionEndingCancelEventArgs e) { //处理一些事情 DoExit(); }