Hi.
I'm new to Xamarin.Forms and I need a bit of guidance.
What I'm trying to do :
Control is located in the shared project.
From what I understand there is no way to access calendar from Xamarin.Forms shared project?
It seems that I will have to write platform specific code for iOS and Android to get the Calendar data.
How can I feed this data back to my third party calendar view control, from Android and iOS?
My best guess at the moment is that I can follow documentation on Calendar for Xamarin.Android and Xamarin.iOS, and use this code to get the data on both platforms. But I'm not sure how can I feed this data back to my control residing in the shared project.
Any kind of guidance is welcome. Thanks!
Answers
I realized that I can access Static class from the Android platform project.
My guess is that I could reference my control in this class and access it this way?
Is this alright approach?
Anyhow, if I'm right I should be able to achieve what I originally planned -> Getting list of events on Android platform and then converting them to usable format for the View in page.
However following this tutorial : https://docs.microsoft.com/en-us/xamarin/android/user-interface/controls/calendar
I've run into an issue -> it's very platform specific related to binding to UI.
I Just need array/list of data and I'm not quite sure how can I grab it because one of the steps binds data to UI directly.
Any tip on that is appreciated.
Thanks!
There are a lot of excellent calendar plugin , and you don't need to access data from specific platform.
https://www.syncfusion.com/xamarin-ui-controls/calendar
https://github.com/rebeccaXam/XamForms.Controls.Calendar
Hey,
Yep, I'm using the Synfusion Calendar!
But I didn't see anything in their documentation that would help me show the events from the local calendar on the device.
Am I wrong?
That's why I wanted to convert the data myself, but if I overlooked an built-in way to do this with SfCalendar please let me know!
Why you want to convert the data , in other words , which data format would you want ?
I was under impression that there was no other way. That's why I wanted to read data on specific platform and feed it to the Calendar in form of "CalendarEventCollection".
But now that you mentioned that I don't need to do this with SfCalendar, perhaps I overlooked a built-in way to get Sfcalendar to read and write Calendar data?
Hey Again!
I have figured out how to grab data on the platform.
However, I'm now back at the original question for Xamarin.Forms :
From Project.Android, how can I access a control on a page in the main shared Xamarin.Forms project?
Example :
Project :
MainPage -> Has a control that I want to feed data to
Project.Android :
CalendarEventsAdapter.cs -> Can I access control on MainPage from here?
Project.iOS
/...
I did manage to "feed" the data to a list in Static Class residing in the Shared project, but I would like to know how to do this properly.
By the way, I would also like to know how to properly execute some code from Shared project in Android project.
I assume for adding and removing Calendar entries, I will need to run some code on platform specific projects.
Thank you!