7

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 SaveAsyncI 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):

IsHidden property has setter

(The app targets Win 10 Build 10586 - maybe it's new, but unfinished?)

Heinrich Ulbricht
  • 10,064
  • 4
  • 54
  • 85
  • 1
    Hi Heinrich, thank you for reporting this, you are indeed not supposed to be able to set IsHidden. I've escalated this to Microsoft and they have filed a BR internally, which is linked to this UV item https://wpdev.uservoice.com/forums/110705-universal-windows-platform/suggestions/15278775-appointmentcalendar-ishidden-setter-throws-a-inval. – Lance McCarthy Jul 19 '16 at 16:56
  • @Lance No problem and thanks very much. Sad though the API betrayed me. – Heinrich Ulbricht Jul 19 '16 at 18:30
  • 1
    Can you confirm if you're using the 106586 SDK or are you using the 14393 Preview SDK? There appears to be an option available for you, which I'll share once I get confirmation from the team. – Lance McCarthy Jul 20 '16 at 16:45
  • @Lance The identity of my Universal Windows SDK in Visual Studio is: `UAP,Version=10.0.10586.0` – Heinrich Ulbricht Jul 21 '16 at 18:14
  • @Lance Any news on the mentioned option? In the meantime I found another bug: https://wpdev.uservoice.com/forums/110705-universal-windows-platform/suggestions/15446178-bug-findappointmentsasync-does-not-return-correct ... – Heinrich Ulbricht Jul 28 '16 at 20:30
  • 1
    I haven't heard any update on the IsHidden issue, but they do have my repo app and are looking at it. I'll let you know as soon as I do. – Lance McCarthy Jul 29 '16 at 12:00

2 Answers2

4

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.

DotNetRussell
  • 9,716
  • 10
  • 56
  • 111
  • 1
    You are right! The docs claim it's read-only. It compiles, though - I added a screenshot from Visual Studio. But the behaviour suggests the documentation is right at this point. Good catch. I should try to get official input on this. – Heinrich Ulbricht Jul 19 '16 at 06:12
1

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

Clint Rutkas
  • 280
  • 2
  • 8
  • Thanks for the confirmation, good to see you guys around here. In the age of fast developing APIs these kinds of issues will be a challenge for platforms like Stack Overflow. I voted on the Uservoice issue and hope to hide my calendar some day ;) – Heinrich Ulbricht Jul 19 '16 at 18:28
  • Yeah good to see you guys around here. I wonder how they found out so quick ;-) – DotNetRussell Jul 24 '16 at 18:59
  • @Clint After updating Win 10 to Anniversary and switching the SDK to 10.0.14393.0 the problem persists, same exception. DeleteAsync() is giving me an InvalidAccessException as well. What could be wrong here? – Heinrich Ulbricht Aug 30 '16 at 20:16
  • both your min and target are 14393? – Clint Rutkas Sep 01 '16 at 16:14