I'm struggling to pass a message from my Android project to my PCL project using MessagingCenter.
In my PCL project, I have a ContentPage called "AboutPage", while on the Android project I have a ScaleImageView class that inherits from ImageView.
When an event occurs on ScaleImageView, I want to pass a message to the AboutPage. Here's what I have so far...
On ScaleImageView.cs
var mp = App.Current.MainPage;
MessagingCenter.Send<AboutPage, string>((AboutPage)mp, "PageSwipe", "NextPage");
On AboutPage
MessagingCenter.Subscribe<AboutPage, string>(this, "PageSwipe", (sender, arg) =>
{
DisplayAlert("Message Received", "arg=" + arg, "OK");
});
But this is not working, I get an error when the MessagingCenter code executes, which I wrote based on this post...
https://forums.xamarin.com/discussion/26681/need-to-get-message-back-to-forms-pcl-from-android-prj