-1

I am prety new with Renderers on Xamarin. I am following this tutorial (https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/custom-renderer/map/customized-pin/) to make a custom pin. The problem it's the following:

I need to do a custom pin, the custom pin only has 2 default labels and 1 Button. That button needs open a page from PCL project. How can I do that click button go to PCL page?

Frein
  • 45
  • 8
  • You could refer to : https://stackoverflow.com/questions/44406120/calling-naviation-pushasync-from-custommaprenderer-when-clicked-on-a-marker/44427338#44427338 – York Shen Nov 01 '17 at 01:36

1 Answers1

3

You can send a message from your custom MapRenderer whenever a pin is clicked using the Xamarin MessagingCenter like so:

Xamarin.Forms.MessagingCenter.Send(YourObject, "PinClicked");

And then subscribe to that message somewhere in your PCL, like so:

MessagingCenter.Subscribe<string> (this, "PinClicked", (YourObject) => {
            // show the correct page whenever the "PinClicked" message 
            // is sent, using the details in YourObject
        });
    });

Don't forget to unsubscribe when you no longer wish to receive messages.

David Conlisk
  • 3,387
  • 4
  • 33
  • 39