事件聚合器未在 Xamarin Forms 的 Prism 7.0 中发布
Event Aggregators not publishing in Prism 7.0 for Xamarin Forms
我最近将我的 Xamarin 表单应用程序项目从 Prism 6.3 更新到 Prism 7.0。除了正确订阅但似乎没有发布的事件聚合器之外,一切似乎都运行良好。
这是我使用的部分代码
public ConfigureInventoryEventViewModel(IEventAggregator ea, INavigationService navigationService):base(navigationService,ea)
{
TappedBackCommand = new DelegateCommand(TappedBack);
_ea.GetEvent<SetLocationEvent>().Subscribe(SetLocationDropdown,true);
}
我正在从模态页面发布活动
public ModalPopupViewModel(IEventAggregator ea, INavigationService
navigationService):base(navigationService,ea)
{
ItemTappedCommand = new DelegateCommand<string>(ItemTapped);
}
private void ItemTapped(string strItem)
{
_ea.GetEvent<SetLocationEvent>().Publish();
}
事件class:
public class SetLocationEvent:PubSubEvent
{
}
请帮忙。
Xamarin 表单 version:2.5.0.280555
Prism.forms:7.0.0396
谢谢
我想你忘了这个:_ea = ea
public ConfigureInventoryEventViewModel(IEventAggregator ea, INavigationService navigationService):base(navigationService,ea)
{
_ea = ea;
TappedBackCommand = new DelegateCommand(TappedBack);
_ea.GetEvent<SetLocationEvent>().Subscribe(SetLocationDropdown,true);
}
public ModalPopupViewModel(IEventAggregator ea, INavigationService navigationService):base(navigationService,ea)
{
_ea = ea;
ItemTappedCommand = new DelegateCommand<string>(ItemTapped);
}
我最近将我的 Xamarin 表单应用程序项目从 Prism 6.3 更新到 Prism 7.0。除了正确订阅但似乎没有发布的事件聚合器之外,一切似乎都运行良好。
这是我使用的部分代码
public ConfigureInventoryEventViewModel(IEventAggregator ea, INavigationService navigationService):base(navigationService,ea)
{
TappedBackCommand = new DelegateCommand(TappedBack);
_ea.GetEvent<SetLocationEvent>().Subscribe(SetLocationDropdown,true);
}
我正在从模态页面发布活动
public ModalPopupViewModel(IEventAggregator ea, INavigationService
navigationService):base(navigationService,ea)
{
ItemTappedCommand = new DelegateCommand<string>(ItemTapped);
}
private void ItemTapped(string strItem)
{
_ea.GetEvent<SetLocationEvent>().Publish();
}
事件class:
public class SetLocationEvent:PubSubEvent
{
}
请帮忙。
Xamarin 表单 version:2.5.0.280555 Prism.forms:7.0.0396
谢谢
我想你忘了这个:_ea = ea
public ConfigureInventoryEventViewModel(IEventAggregator ea, INavigationService navigationService):base(navigationService,ea)
{
_ea = ea;
TappedBackCommand = new DelegateCommand(TappedBack);
_ea.GetEvent<SetLocationEvent>().Subscribe(SetLocationDropdown,true);
}
public ModalPopupViewModel(IEventAggregator ea, INavigationService navigationService):base(navigationService,ea)
{
_ea = ea;
ItemTappedCommand = new DelegateCommand<string>(ItemTapped);
}