Reputation:
I am new to mobile development. For this i am practicing on xamarin forms and following this sample code. But there are some issues in it which i couldn't understand.
First is that there is no Mainpage.xaml
file in the solution, i have to add it manually like bellow image
Further more in sample code they said to copy paste app.xaml.cs
code into my solution file with same name. But there is no such file named like this as also shown in the above image. But i do have app.cs
file so i copy pasted that code into this file and i get the following error
Moreover when i run it i get a following message
I have searched many articles on this but couldn't find the right answer
Any help would be highly appreciated
Upvotes: 0
Views: 386
Reputation: 101
Looking at the quickstart it references the Blank Xaml App(Xamarin.Forms Portable) template. When checking my own Visual Studio 2015(Windows 10) this template doesn't exist and creating a Blank App(Xamarin.Forms Portable leaves me in a similar situation to your own; no Mainpage.xaml.
In a forms project the app.cs class is used to initialize your layout. This is not the same as a App.xaml.cs; App.xaml.cs would be a backing file for an associated App.xaml file. You could try looking at this related question to see if that template will layout what you need. Although, looking again at the quickstart it seems like it's no longer in line with the sample project. Instead of replacing all of the code in App.cs, it should be fine to replace
MainPage = new ContentPage
{
Content = new StackLayout
{
VerticalOptions = LayoutOptions.Center,
Children = {
new Label {
XAlign = TextAlignment.Center,
Text = "Welcome to Xamarin Forms!"
}
}
}
};
with
MainPage = new MainPage();
This should be enough to tell the app that you want your default page to be the MainPage they had you make earlier. Hope this helps.
Upvotes: 1