Xamarin形成Prism如何在iOS项目中使用IEventAggregator

编程入门 行业动态 更新时间:2024-10-26 22:16:31
本文介绍了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

本文发布于:2023-10-07 10:29:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1469142.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:项目   如何在   Prism   Xamarin   iOS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!