When I have created a new XAML file and XAML.cs , Its showing that InitializeComponent() is not found in the current file , but when I have tried restarting the VS Code It was working , but now again I have added few changes it is still showing the same issue and unable to Run.
Tried Restarting and also added new files by deleting the existing page and adding it again .
I do not know about VS Code, but on VS 2022 you need to watch for 3 things.
The names must match before .xaml, and .xaml.cs
Build action for the .xaml should be MauiXaml, and for the .cs C# compiler.
The x:Class
in the .xaml should point to the right namespace and class name.
(In most cases of this error, people changed the namespace, by moving the file to another directory.)