Xamarin Forms MessagingCenter 收不到消息
Xamarin Forms MessagingCenter does not receive message
我已经从这个 link 下载了 MultiImagePicker:https://github.com/danielkon96/MultiImagePickerand 它工作正常,没有任何问题。当我添加所有接口和 类 并且...在我的项目中时,MessagingCenter 没有收到消息。
上传页面中的按钮点击:
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;
}
});
MainActivity 中的 OnActivityResult :
MessagingCenter.Send<App, List<string>>((App)Xamarin.Forms.Application.Current, "ImagesSelectedAndroid", images);
有什么问题吗?
感谢@pinedax 在 中的回答 我已经通过此更改解决了我的问题 :
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) =>
和
MessagingCenter.Send<Xamarin.Forms.Application, List<string>>(Xamarin.Forms.Application.Current, "ImagesSelectedAndroid", images);
我已经从这个 link 下载了 MultiImagePicker:https://github.com/danielkon96/MultiImagePickerand 它工作正常,没有任何问题。当我添加所有接口和 类 并且...在我的项目中时,MessagingCenter 没有收到消息。
上传页面中的按钮点击:
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;
}
});
MainActivity 中的 OnActivityResult :
MessagingCenter.Send<App, List<string>>((App)Xamarin.Forms.Application.Current, "ImagesSelectedAndroid", images);
有什么问题吗?
感谢@pinedax 在
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) =>
和
MessagingCenter.Send<Xamarin.Forms.Application, List<string>>(Xamarin.Forms.Application.Current, "ImagesSelectedAndroid", images);