views:

19

answers:

1

Hello,

I have a CustomerListViewModel and a OrderListViewModel. In the latter I select an order to delete it or I create a new one. In both situations my CustomerListViewModel and the Messenger must register to the type IOrder:

Messenger.Default.Register<IOrder>(this, AddOrder);
Messenger.Default.Register<IOrder>(this, DeleteOrder);

In the OrderListViewModel I do send the customer to be deleted/added:

Messenger.Default.Send<IOrder>(MyOrderObject);

Now both Actions AddOrder and DeleteOrder gets surely executed, how can I differentiate ?
A: 

The owner does not send any hint, if it is insert or delete. Hence, the receiver can only guess or find out by himself. My suggestion is to introduce additional message-types (IAddOrder, IDeleteOrder), s.t. the sender has an interface to tell about the type of change. If this is not possibe, you would need to add some information into the IOrder, but that would be just a smelly workaround, because the data is no longer needed after exchanging the message.

Simpzon