My WPF Application cannot locate resource 'Mainwindow.xaml' My WPF Application cannot locate resource 'Mainwindow.xaml' wpf wpf

My WPF Application cannot locate resource 'Mainwindow.xaml'


Change the StartupUri="MainWindow.xaml" to StartupUri="FolderName/MainWindow.xaml"

Solved my problem, when I moved my MainWindow to the View Folder


In my case I needed to use pack URI syntax to set SrartUpUri property of my App.xaml file to point to a new location of my MainWindow.xaml, as so:

   <Application x:Class="TrafficLights.Controller.App"                xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"                StartupUri="pack://application:,,,/View/MainWindow.xaml">

More on pack URIs here:

http://msdn.microsoft.com/en-us/library/aa970069(v=vs.110).aspx

Hope it helps. Good luck!


This happened to me few times - always when I moved MainWindow.xaml to different folder and forgot to update StartupUri in App.xaml.