Now that\'s a real strange error. I am working on a WPF application and following MVVM. In my MainWindow I am setting views and view models and I get this strange error. Alt
clr-namespace:MyProject.ViewModels
There has to be a namespace called MyProject.ViewModels that has a class Called MainPageViewModel that is public and has a public parameterless constructor within the same assembly as ProjectDatabaseRebuilder.MainWindow.
There is not.
If MyProject.ViewModels exists in a referenced assembly, you must state so within the xmlns.
xmlns:vm="clr-namespace:MyProject.ViewModels;assembly=MyProject"
or some such. Honestly, it looks like you copypasted someone's example without realizing how these specialized xml namespaces work in WPF.
Something tells me the ultimate answer will be the following: xmlns:vm="clr-namespace:ProjectDatabaseRebuilder.ViewModels".
Please note that "namespace" and (as above) "assembly" mean namespaces and assemblies, and the xaml deserializer uses this information to locate types at runtime. If they are incorrect, things won't work.
This is trivial. You must have done something weird with your project, which might necessitate you start from scratch. Or, you can make a new project following my guide below, and then compare it bit by bit to yours to see where you went wrong.
First, create a new WPF application called MyWpfApplication.
Add a folder for Views and one for ViewModels. Add the shown VM code class and view UserControl:

In your code class, add the following:
namespace MyWpfApplication.ViewModels
{
class MainWindowViewModel
{
public string Text { get; set; }
public MainWindowViewModel()
{
Text = "It works.";
}
}
}
Your View is also simple:
And, in your Window, do essentially what you are attempting to do:
And, when run, you should see everything as expected:

Do this, then compare the working solution to your project. If you can't find any differences, you probably need to just scrap your solution and start fresh. Copy code, not files, into the new solution.