简体   繁体   中英

Xamarin Forms MessagingCenter does not receive message

I have downloaded MultiImagePicker from this link: https://github.com/danielkon96/MultiImagePickerand it's working fine without any problem. When I add all interfaces and classes and... in my project, the MessagingCenter does not receive message.

ButtonClick in UploadPage:

MessagingCenter.Unsubscribe<App, List<string>>((App)Xamarin.Forms.Application.Current, "ImagesSelectedAndroid");
MessagingCenter.Subscribe<App, List<string>>((App)Xamarin.Forms.Application.Current, "ImagesSelectedAndroid", (s, images) =>
{
   if (images.Count > 0)
   {
      ImgCarouselView.ItemsSource = images;
      InfoText.IsVisible = true;
   }
});

OnActivityResult in MainActivity:

MessagingCenter.Send<App, List<string>>((App)Xamarin.Forms.Application.Current, "ImagesSelectedAndroid", images);

What's the problem?

Thanks to @pinedax for his answer in this question I have solved my problem by this changes:

MessagingCenter.Unsubscribe<Xamarin.Forms.Application, List<string>>(Xamarin.Forms.Application.Current, "ImagesSelectedAndroid");

MessagingCenter.Subscribe<Xamarin.Forms.Application, List<string>>(Xamarin.Forms.Application.Current, "ImagesSelectedAndroid", (s, images) =>

and

MessagingCenter.Send<Xamarin.Forms.Application, List<string>>(Xamarin.Forms.Application.Current, "ImagesSelectedAndroid", images);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM