Forum Xamarin.Forms


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Accessing controls on the Shared project from the platform projects

HamsterHamster RSMember ✭✭

I'm new to Xamarin.Forms and I need a bit of guidance.

What I'm trying to do :

  • Feed the device's calendar data (events, appointments, etc.) to the Third Party Calendar Xamarin.Forms control

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!


  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭
    I think there is a good plugin on GitHub. I don’t remember the link
  • HamsterHamster RSMember ✭✭

    @AlessandroCaliaro said:
    I think there is a good plugin on GitHub. I don’t remember the link

    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 :

    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.


  • ColeXColeX Member, Xamarin Team Xamurai
    edited April 2019

    There are a lot of excellent calendar plugin , and you don't need to access data from specific platform.

  • HamsterHamster RSMember ✭✭

    @ColeX said:
    There are a lot of excellent calendar plugin , and you don't need to access data from specific platform.

    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!

  • ColeXColeX Member, Xamarin Team Xamurai

    Why you want to convert the data , in other words , which data format would you want ?

  • HamsterHamster RSMember ✭✭

    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?

  • HamsterHamster RSMember ✭✭

    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?

    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!

Sign In or Register to comment.