1

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

这是我使用的代码的一部分

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 表单版本:2.5.0.280555 Prism.forms:7.0.0396

谢谢

4

1 回答 1

1

我想你忘记了这一点:_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);
}
于 2018-06-14T02:04:30.333 回答