You don't put Application
tag into your Window
. In your solution you have app.xaml
where you should put your:
ShutdownMode="OnMainWindowClose"
and quoting MSDN:
MainWindow is automatically set with a reference to the first Window object to be instantiated in the AppDomain.