Search code examples
androidxamarinxamarin.formscalendarviewxlabs

Xamarin XLabs Forms CalendarView not working on Android


I'm using the CalendarView control in Xamarin Forms from the XLabs Nuget package in Xamarin Studio.

The CalendarView is defined as below, but no Calendar is shown on the android device:

using System;

using Xamarin.Forms;
using XLabs.Forms.Controls;

namespace CustomRenderer
{
public class MyPage : ContentPage
{
    public MyPage()
    {
        CalendarView calendarView = new XLabs.Forms.Controls.CalendarView 
            {
                MinDate = new DateTime(2016, 1,1),
                MaxDate = new DateTime(2016, 1, 31),
                VerticalOptions = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                ShowNavigationArrows = true,

                DateBackgroundColor = Color.White,
                IsVisible = true,
            };

        calendarView.DateSelected += (object sender, DateTime e) => {

        };
        Content = new StackLayout
        { 

                HeightRequest = 400,
                WidthRequest = 320,
            Children =
            {
                calendarView
            }
        };
    }
}
}

Solution

  • Remember to initialize the MainActivity with

    MainActivity : XFormsApplicationDroid
    

    AND add XLabs to the Droid project as well. It's working now.