My app needs an internal calendar. I can create a new calendar like this:
var store = await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AppCalendarsReadWrite);
var cacheCalendar = await store.CreateAppointmentCalendarAsync("unique name here");
This succeeds and I get a new calendar. But this calendar is visible in the phone's built-in calendar app. I don't want this calendar to be visible since it's for internal bookkeeping.
So I try to hide the calendar like this:
var store = await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AppCalendarsReadWrite);
var cacheCalendar = await store.CreateAppointmentCalendarAsync("unique name here");
cacheCalendar.IsHidden = true; // <---- make calendar hidden
await cacheCalendar.SaveAsync(); // <---- save; error here
When calling SaveAsync
I get the following exception:
Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))"
Why can't I hide my calendar from the built-in phone calendar app? Is this an undocumented limitation? Are there other ways to do this?
(Note: I tested this on a Windows 10 Mobile as well as desktop Win 10 - same error.)
Edit/Addition: Since Anthony discovered the IsHidden
property is documented as read-only in MSDN here is a screenshot from Visual Studio showing the public setter (which makes it compile, run and seemingly legit to call):
(The app targets Win 10 Build 10586 - maybe it's new, but unfinished?)
Honestly I am surprised this even compiles.
According to the MSDN documentation for AppointmentCalandar
IsHidden - Read-only - Gets whether the AppointmentCalendar is hidden in the device's built-in calendar UI
This is a read only property and can't be set.
As for your actual question, after carfully reviewing the documentation it appears that this is an oversight in the API. I would raise this concern on the MSDN forums.
This was a bug in 10586 but if you’re using 14393 SDK you can use IsHidden if your app has rights to the calendar without an InvalidAccessException
https://wpdev.uservoice.com/forums/110705-universal-windows-platform/suggestions/15278775-appointmentcalendar-ishidden-setter-throws-a-inval
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With