VS2017 Cross Platform Xamarin Forms Development and Passing Data

I have a cross platform application I am working on which each device platform connects to a WCF service to get specific information from a database. We only want our service connecting to the database, not the apps. This information needs to be passed to the UI's (xaml) and I am having a hard time with it. So I have 5 projects

Apps (Shared)
Apps.Android
Apps.IOS
Apps.WCFService
Apps.UMP

Most of my work is done in the Android project now and the Service project. As of right now everything is working fine and I can call on my service from the Android project and get requested information. I have all the data in the MainActivity class in the Android project. So at this point, I need to send the data to the xaml pages in the Shared xaml files in order to add to controls and display to users.

I am not finding a way to do this yet. Any help would be appreciated.

Best Answer

  • KhilbornKhilborn ✭✭
    Accepted Answer

    Got it working, thanks. Used a DependecyService to get data from a specific device project to the Xamarin Forms shared project.. I will be using MessagingCenter to pass data between Xamarin Forms

Answers

  • robbitrobbit CNMember Xamurai
    edited June 2018

    I have all the data in the MainActivity class in the Android project. So at this point, I need to send the data to the xaml pages in the Shared xaml files in order to add to controls and display to users

    You can use MessagingCenter. With the MessagingCenter, you can send the data from Android platform and receive the data in PCL's page( PCL is your "Apps (Shared)" ). And here is a blog about how to use it.

  • KhilbornKhilborn Member ✭✭
    Accepted Answer

    Got it working, thanks. Used a DependecyService to get data from a specific device project to the Xamarin Forms shared project.. I will be using MessagingCenter to pass data between Xamarin Forms

Sign In or Register to comment.