TheAlmightyBob / Calendars

Cross-platform calendar API plugin for Xamarin and Windows
MIT License
101 stars 23 forks source link

GetCalendarsAsync(); #76

Closed mrrcomp closed 4 years ago

mrrcomp commented 4 years ago

Hi

I am using the below code public List CNames; public IList calenders;

    public MainPage()
    {

        InitializeComponent();
        var ignore= GetCalendars();

        foreach (var item in calenders)
        {
            CNames.Add(item.Name);
        }

        MyList1.ItemsSource = CNames;
        string v = calenders.First().Name.ToString();
        MyCalendar.Text = v;
        // ...figure out which calendar to use, e.g. by prompting the user and considering the CanEditEvents property...

        var calendarEvent = new CalendarEvent
        {
            Name = "Add calendar support",
            Start = DateTime.Now.AddMinutes(30),
            End = DateTime.Now.AddMinutes(50),
            Description = "TestSoftware",
            Reminders = new List<CalendarEventReminder> { new CalendarEventReminder()
                }

        };

    }
    public async Task GetCalendars() {

        calenders = await CrossCalendars.Current.GetCalendarsAsync();

    }
}

But the GetCalendarsAsync return null list??

Suggestions ?

Regards

Meir

TheAlmightyBob commented 4 years ago

@mrrcomp Is GetCalendarsAsync returning null or an empty list? Are you certain that there are calendars present on the device? For example, an Android emulator will by default have zero calendars.