ComponentOne Xamarin.iOS Documentation
Controls / Calendar / Quick Start: Display a C1Calendar Control
In This Topic
    Quick Start: Display a C1Calendar Control
    In This Topic

    This section describes how to add a C1Calendar control to your iOS app and select a date on the calendar at runtime.

    The following image shows how C1Calendar appears after completing the above steps.

    Step 1: Initialize Calendar control in code

    To initialize a C1Calendar control, open the ViewController file from the Solution Explorer and replace its code with the code below. This code overrides the ViewDidLoad method of the View controller in order to initialize a C1Calendar.

    C#
    Copy Code
    using C1.iOS.Calendar;
    using CoreGraphics;
    using System;
    using UIKit;
    
    namespace CalendariOS
    {
        public partial class ViewController : UIViewController
        {
            //Initialize Calendar controlS
            C1Calendar calendar = new C1Calendar();
            public ViewController(IntPtr handle) : base(handle)
            {
            }
            public override void ViewDidLoad()
            {
               base.ViewDidLoad();
               this.Add(calendar);
            }
            public override void ViewDidLayoutSubviews()
            {
                base.ViewDidLayoutSubviews();
                calendar.Frame = new CGRect(this.View.Frame.X, this.View.Frame.Y,
                 this.View.Frame.Width, this.View.Frame.Height);
            }
        }
    }
    

    Step 2: Run the Application

    Press F5 to run the application.