public MainWindow() { if (Self != null) { throw new Exception("Cannot initialize more than one MainWindow."); } Self = this; InitializeComponent(); Closed += (sender, args) => _dm.Shutdown(); AppDomain.CurrentDomain.UnhandledException += (sender, e) => LogControl.Error(e.ExceptionObject as Exception); KeyDown += (s, e) => _dm.Key = e.Key.ToString().ToLower(); KeyUp += (s, e) => _dm.Key = string.Empty; ContentRendered += (s, e) => Focus(); Closing += MainWindow_Closing; }