事件聚合器不在Prism 7.0中发布Xamarin Forms

时间:2018-03-07 07:25:28

标签: xamarin.forms eventaggregator prism-7

我最近将我的Xamarin表单应用程序项目从Prism 6.3更新为Prism 7.0。除了eventggregators正确订阅但似乎没有发布之外,一切似乎都运行良好。

以下是我使用的代码的一部分

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();
}

活动类:

public class SetLocationEvent:PubSubEvent
{
}

请帮忙。

Xamarin Forms版本:2.5.0.280555 Prism.forms:7.0.0396

由于

1 个答案:

答案 0 :(得分:0)

我想你忘记了这一点:_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);
}