Notifications XMessageControl UIMessage在monodroid上不工作

Notifications XMessageControl UIMessage在monodroid上不工作,notifications,xamarin.android,xamarin.forms,renderer,Notifications,Xamarin.android,Xamarin.forms,Renderer,我正在尝试更改在Xamarin.forms项目上显示通知的方式,并且在添加组件时,它不会显示消息或toast UIMessage.ShowMessage ("Customization", "Hey! You Clicked on Button", MessageControl.MessageTypes.Warning, "red.png", Color.BrandRed, Color.Black, true, OnDissmissControl); 我从一个依赖控制器运行这段代码,我想知道错

我正在尝试更改在Xamarin.forms项目上显示通知的方式,并且在添加组件时,它不会显示消息或toast

UIMessage.ShowMessage ("Customization", "Hey! You Clicked on Button", MessageControl.MessageTypes.Warning, "red.png", Color.BrandRed, Color.Black, true, OnDissmissControl);

我从一个依赖控制器运行这段代码,我想知道错误是否是由于没有正确的上下文造成的,但我看不到向类中添加上下文的方法。是否有人尝试在Xamarin.forms项目中使用此组件?(这是MonoDroid特有的)。

答案是,只需确保您在主线程上运行,它就可以工作了。如果库中有一些值得一看的文档,这会容易得多

    [assembly: Xamarin.Forms.Dependency (typeof (.Android.MessageBar))]
namespace .Android
{
    public class MessageBar : IMessageBar
    {
        public MessageBar ()
        {
        }

        public void Show(MessageType messageType, string title, string message)
        {
            var context = Forms.Context;

            Device.BeginInvokeOnMainThread (() => {
                //CustomToast customtoast=new CustomToast(context, messageType, title, message);
                UIMessage.ShowMessage ("Customization", "Hey! You Clicked on Button", MessageControl.MessageTypes.Warning, "validation.png", Color.BrandRed, Color.Black, true, OnDissmissControl);

            });


        }
        public void OnDissmissControl()
        {

        }
    }
}