Cześć :)
Próbuję ogarnąć Event Aggregator w Prism, ale coś mi nie idzie.
Poniższy kod piszę z palca, więc przepraszam za ewentualne literówki.
- MainWindowViewModel
public class MainWindowViewModel : BindableBase
{
IEventAggregator _eventAggregator;
public MainWindowViewModel(IEventAggregator ea)
{
_eventAggregator = ea;
send();
}
private void send()
{
_eventAggregator.GetEvent<DataSentEvent>().Publish("STOCK0");
_ = new SecondWindowView().ShowDialog();
}
}
- SecondWindowViewModel
public class SecondWindowViewModel : BindableBase
{
public SecondWindowViewModel (IEventAggregator ea)
{
ea.GetEvent<DataSentEvent>().Subscribe(Received);
}
void Received(string txt)
{
MessageBox.Show(txt);
}
}
- Event
public class DataSentEvent : PubSubEvent<string>{}
I niestety nie działa...
Metoda "Received" w ogóle się nie uruchamia.
Postawiłem na niej breakpoint i debugger go omija - przechodzi do kolejnego breakpointu.
Co zrobiłem źle?