Firstly I am very new to xamarin, and I am using visual studio 2017 and I have encountered a problem in how to work with cross platforms in xamarin. The Cross-Platform has two forms first is a blank app and second is master details. I select the blank app and see that there are three axml files- MainPage.axml, Toolbar.axml, Tabbar.axml. Can someone tell me in which file I add buttons, textfields to able to show the design of my app.
Posts
You dont have to add the buttons to any of these pages you can create your own pages and fill them with the controls you desire.
Which pages you create and what controls you put into them is up to you!
This is NotificationHelper.xaml.cs Class, In this I am getting errors in GetSystemService, NotificationService, GetString saying 'GetSystemService does not exist in the current context' and same is for NotificationService and GetString.
The base keyword is not working saying 'ContentPage does not contain a constructor that takes 1 argument' and also the GetNotification1(String title, String body) saying" 'NotificationHelper.String': static types cannot be used as parameters' ".
The whole code is a mess, I cannot resolve these errors.
You are mixing Xamarin.Android code with Xamarin.Forms code. So yes, the whole code is a mess. Is this a template? It is not any starter template I have seen.
Please go over this getting started guide for Xamarin Forms: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/get-started/
When working with Xamarin Forms, you are dealing with multiple projects that each have some restrictions as to what code can be put in that project. There is a Core project that you can put Xamarin.Forms controls and pages in as well as any code that is identical for all of the platform projects in your solution. Then there are projects for each platform you are supporting, e.g. Android, iOS, UWP, etc. Xamarin Forms code and types should go in the Core project, while any platform specific code, i.e. code that would work in Android but not in iOS, needs to go in the platform specific project, i.e. in the Android project for code that would work in Android but not in iOS, etc.
What I see in your code above is Android specific code (
GetSystemService
,NotificationService
,GetString
) in aContentPage
, which is a Xamarin.Forms type. This leads me to believe that you are putting Android specific code in the common Core project that has a restriction that no platform specific code can be directly put in that project, hence the 'GetSystemService does not exist in the current context' errors.(More correctly, platform specific cade can be put into the core project IF the core project is a Shared project type, not a PCL or .NET Standard project, but even then the Platform specific code would have to be bounded by #ifdef/#endif compiler directives, which are not present in your code above.)
Yes, you have a base class of ContentPage which indeed does not have a constructor that takes one parameter. This is again because you are trying to subclass a Xamarin.Forms type,
ContentPage
, but using Android specific code added to the subclass, and implementing a constructor with code copied from an Android type.)I highly recommend Xamarin University for instructor led classes that start from the basics of programming with C# up to using Xamarin at an advanced level.
Thanks, Sir but I already corrected that error and I Just dropped this project and creating a new one. And try to create a new one but I didn't find one on the internet so I want you to suggest me where I can get the code for this project.
And about that mixing thing I already corrected that by first understanding the difference between Xamarin Android and Xamrin forms, I have created some small projects in the xamarin forms to understand it better.
The course you were talking about is helpful or just like some tutorial videos on youtube?
You want to create a project but you cant find it on the internet are you suggesting you are unable to create a blank project and make it into an App. If thats the case stop developing.
from the Xamarin University link provided earlier: