Xamarin形成Prism如何在iOS项目中使用IEventAggregator [英] Xamarin forms Prism how can I use IEventAggregator in iOS project

查看:59
本文介绍了Xamarin形成Prism如何在iOS项目中使用IEventAggregator的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是如何在Xamarin.Forms的iOS项目的类中使用IEventAggregator来发布消息.

My question is how can I use the IEventAggregator inside a class in iOS project of Xamarin.Forms to publish a message.

IEventAggregator作为构造函数参数传递似乎无效.似乎该依赖关系无法在iOS项目中解决.因此,如何解决iOS项目中IEventAggregator的依赖关系,以便可以在类中使用它进行发布.

Passing the IEventAggregator as a constructor parameter doesn’t seems to work. It seems that the dependency cannot be resolved in the iOS project. So how can I resolve the dependency of IEventAggregator in the iOS project so I can use in a class to publish.

我正在使用Prism 6.3.0

I'm using Prism 6.3.0

推荐答案

PrismApplication的容器是公共属性.因此,您可以访问容器来解决您的依赖性,例如:

PrismApplication's Container is a public property. You can thus access the container to resolve your dependency like:

var ea = ((App)Application.Current).Container.Resolve<IEventAggregator>();
ea.GetEvent<SomeEvent>().Publish(somePayload);

这篇关于Xamarin形成Prism如何在iOS项目中使用IEventAggregator的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆