I got some requests from users of my app ‚Week View‚, if i plan to „port“ it to windows 8.1.
When offering a calendar app for windows 8.1 I wanted to provide some „exta value“ – features the built in calendar does not offer. So my reply was: „Yes, I am thinking about this – what should this app look like and which features do you miss in the windows 8.1 built in calendar?“
With „universal apps“, which were introduced at the MS Build 2014 conference from MS, creating apps that run on both platforms got even easier and when starting a new project I would definitely do it as a universal app, when possible. (For details, please see http://msdn.microsoft.com/en-us/library/windows/apps/dn609832.aspx)
So I created a universal app to test some basic features that are required to „port“ Week View to Windows 8.1
Basic features in my opinion are:
1. Query for calendars and appointments. As a result get the calendars (windows live, google, exchange, …) that are configured on the device and appointments from these calendars.
2. Create, edit and delete appointments
Quite minimalistic, isn’t it? 😉
Since I already created some windows 8.x apps I knew that periodic live tile updates are simple to do in windows 8.x so I did not care about this at the moment.
The prototype should simply query for appointments and show the result, sorted by calendar type, in a list. Unfortunately this is not possible, which was a big disappointment.
The windows 8.x programing interface provides no methods to do a simple query for calendar appointments. 🙁
In Windows Phone 8.1 the „AppointmentStore“ class is used for these operations. You can query for appointments with these simple lines of code:
var store = await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AllCalendarsReadOnly); // get access to appointments store var calendars = await store.FindAppointmentCalendarsAsync(FindAppointmentCalendarsOptions.None); // query for calendars var appointments = await store.FindAppointmentsAsync(startDateInclusive, timeSpan, findAppointmentsOptions); // query for appointments
Really simple and these methods are used in Week View 8.1 to get calendars and appointments.
Although these methods are part of the WinRT for windows phone, they are not included in WinRT for windows 8.x.
WinRT for windows 8.x allows to open the build in calendar to create/edit/delete existing appointments but simply getting a list of existing appointments – for example to show them on a live tile is not supported. 🙁
Hint: Some WinRT apps make use of the share-contract and can act as a share-source to provide their data for other apps. Unfortunately the built in windows calendar does not implement the share contract and so can not share it’s data (appointments) with other apps.
These is one of the times, when a developer asks: WTF Microsoft did you do this?
Who created this API and did he ever use it? Reading data (appointments) is such a basic thing, you would not even expect that it does NOT work.
A possible „solution“ is to use the windows live API to directly access the windows live calendar, use the google API to directly access the google calendar, use the exchange API to access the exchange calendar and so on…of course this is a very bad solution.
I also posted a question about this in a developer forum: http://social.msdn.microsoft.com/Forums/windowsapps/en-US/26f8474e-a083-41ee-a900-2de16ecb101a/how-can-we-read-appointments-in-calendar?forum=winappswithcsharp&prof=required
One of the replies in this thread describes the current situation exactly: „…there is no method to enumerate all existing appointments of a calendar like in Windows Phone 8.1. I wonder when this method will be available. Until then the Appoitnment class is more or less useless.“