yes, @ right, I also suffered from the same problem when I was new to WPF. Check your x: class in the XAML file, it should contain the namespace used in the code. for example. x: Class = "MainWindow" should be something like x: Class = "namespace.MainWindow" if it does not work, try restarting VS or trying to recreate the project with the correct name, hoping that it will solve your problem.
Abdullah obaidullah
source share