Telerik Calendar with Office365

2 posts, 0 answers
  1. Chris
    Chris avatar
    1 posts
    Member since:
    Aug 2016

    Posted 23 Aug Link to this post

    Hello, I have a Xamarin.Forms with C# application that I am developing. 
    At the moment the user can log in and authenticate using Azure AD. 
    They are then taken to a XAML tabbed page that uses a ‘Telerik’ calendar control. 
    I need to bind the event data from office365 into this control. 
    I also have 2 list views that need to bind data from Office365 through the API. 
    These will be listed as tasks and contacts. 
    The user should be able to add, edit and delete said contacts/tasks. 
    Can anyone assist with this?
    Thanks
  2. Lance | Tech Support Engineer, Sr.
    Admin
    Lance | Tech Support Engineer, Sr. avatar
    138 posts

    Posted 24 Aug Link to this post

    Hi Chris,

    I answered an identical question from Nathan a couple weeks ago, you can find my code examples and explanation there. You can find the thread at this link.

    To summarize, the UI for Xamarin controls do not perform CRUD operations on the O365 API automatically for you. You need to get the data in order to display it in the ListView or Calendar.

    As far as editing operations are concerned, this is also something you need to have implemented so that you can interact with the API.  The user adds or edits the in-memory object and you send the new/changed item back to the API.

    Regarding the ListView
    The ListView isn't as restrictive as the Calendar because you don't need to implement IAppointment interface. You can directly bind the ItemSource of the ListView to whatever IEnumerable object you've loaded the O365 data into.

    In your example, you state that the ListView would be using Contacts and Tasks. So in your ViewModel (or if you're not using MVVM, the code behind), you have your API result already deserialized into a CLR type. 

    For example, heres a simplified Contact class:

    public class Contact
    {
        public string FirstName {get;set;}
        public string LastName {get; set;}
    }


    In your view model/code-behind/service class you'd have a collection of these contacts:

    public ObservableCollection<Contact> Contacts {get;set;}

    private Task<ObservableCollection> GetContactsFromO365Async()
    {
       // Your API logic would be in something like this
    }

    With this you can make a call to your API, and deserialize the response into the Contacts collection. With the Contacts collection populated, you can bind to, or set, the ListView.ItemsSource property and have the appropriate ItemTemplate.

    See this example to learn how to set it programmatically, and here is an example of binding it in the XAML

    <telerik:RadListView x:Name="ContactsListView" ItemsSource="{Binding Contacts}">
        <telerik:RadListView.ItemTemplate>
            <DataTemplate>
                <listView:ListViewTextCell Text="{Binding LastName}"
                                  Detail="{Binding FirstName}"
                                  DetailColor="Gray"/>
            </DataTemplate>
        </telerik:RadListView.ItemTemplate>
    </telerik:RadListView>


    In my above example, I use a ListViewTextCell, but you can use a custom cell to show more of the properties in the Contact class.

    Please note that if you have any further questions, please post in the original thread as this is a duplicate thread. This will allow us to provide you with better support by keeping identical answers in the same place.

    Thank you for contacting Support and for choosing Telerik by Progress.

    Regards,
    Lance | Tech Support Engineer, Sr.
    Telerik by Progress
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. DevCraft banner
Back to Top