I just started learning Xamarin a few days ago. I am now developing an Application using Xamarin.Forms. Now I am having an issue with adding new xaml view to my project. I am now creating a new view and when user click on, a button from the different page, user will be redirected to that view. It is giving me error while I add a new view.
I right click on the Views folder and add new xaml content page like this
Then the xaml file is not added. Please compare my newly added HelloPage and AboutPage below.
Then the class file is throwing following error.
But when I open the file explorer, I can see the XAML file as below.
Is that the bug with Visual Studio? I am using VS 2017. How can I fix the issue? I tried on many solutions like this - Xamarin Forms InitializeComponent does not exist , but it is not helping. I believe that it is throwing "Initialize Component does not exist" error because XAML file is not properly. How can I fix it?
When I build the project, it shows me this error.
In my case, it is "HelloPage.xaml" not the "NewPage.xaml" as in the screenshot.
You should clean, then rebuild solution. Do it a couple of times, if error continues restart visual studio 2017.
Sometimes you have to reset visual studio
I had the same problem when I created a new project. VisualStudio 2017 had named the main page xaml file MainPage.xaml. I renamed MainPage.xaml,MainPage.xaml.cs to something else. This is when I started getting the error. I had changed all the references except for one in the xaml file. In the ContentPage tag, I had forgotten to change the attribute, x:Class="App.MainPage" to x:Class="App.NewPage".
Check your ContentPage tag in your xaml file.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.