【问题标题】:Xamarin Forms Map pin renderer open pageXamarin Forms Map pin 渲染器打开页面
【发布时间】:2018-04-12 10:02:58
【问题描述】:

我对 Xamarin 上的渲染器非常陌生。我正在按照本教程 (https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/custom-renderer/map/customized-pin/) 制作自定义别针。问题如下:

我需要做一个自定义引脚,自定义引脚只有 2 个默认标签和 1 个按钮。该按钮需要从 PCL 项目中打开一个页面。我怎样才能点击按钮转到 PCL 页面?

【问题讨论】:

标签: xamarin xamarin.ios xamarin.forms xamarin.android renderer


【解决方案1】:

您可以在点击 pin using the Xamarin MessagingCenter 时从自定义 MapRenderer 发送消息,如下所示:

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

然后在您的 PCL 中的某处订阅该消息,如下所示:

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

当您不再希望接收消息时,不要忘记取消订阅。

【讨论】:

  • 对不起,我不能很快回答。它就像一个魅力,谢谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-08-23
  • 1970-01-01
  • 2018-07-29
  • 1970-01-01
  • 2016-12-19
相关资源
最近更新 更多