shub1409

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

  • SzbestaSzbesta Member ✭✭✭

    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!

  • shub1409shub1409 Member ✭✭

    using Android;
    using Android.App;
    using Android.Content;
    using Android.Graphics;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using Java.Lang;

    using Xamarin.Forms;
    using Xamarin.Forms.Xaml;

    namespace O_Notification
    {
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class NotificationHelper : ContentPage
    {
    public NotificationHelper()
    {
    InitializeComponent();
    }
    public static class String
    {
    public const int noti_channel_default = 2131165200;
    }

        public const string PRIMARY_CHANNEL = "default";
        NotificationManager manager;
        NotificationManager Manager
        {
            get
            {
                if (manager == null)
                {
                    manager = (NotificationManager)GetSystemService(NotificationService);
                }
                return manager;
            }
        }
    
        int SmallIcon => Android.Resource.Drawable.StatNotifyChat;
    
        public NotificationHelper(Context context) : base(context)
        {
            var chan1 = new NotificationChannel(PRIMARY_CHANNEL,
                    GetString(String.noti_channel_default), NotificationImportance.Default);
            chan1.LightColor = Android.Graphics.Color.Green;
            chan1.LockscreenVisibility = NotificationVisibility.Private;
            Manager.CreateNotificationChannel(chan1);
    
        }
    
        public Notification.Builder GetNotification1(String title, String body)
        {
            return new Notification.Builder(ApplicationContext, PRIMARY_CHANNEL)
                     .SetContentTitle(title)
                     .SetContentText(body)
                     .SetSmallIcon(SmallIcon)
                     .SetAutoCancel(true);
        }
        public void Notify(int id, Notification.Builder notification)
        {
            Manager.Notify(id, notification.Build());
        }
    }
    

    }

    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.

Sign In or Register to comment.