lunes, 20 de agosto de 2012 16:10
I'm using MVVM Light's Messenger class. I'm wondering if this class's should be used only by ViewModels, or if it can be used also by other classes. If it's the latter, then who also can use it? IoC Conainer? Services? Views?
Todas las respuestas
lunes, 20 de agosto de 2012 16:15Moderador
Yes you can use it anywhere within the project that can access it, and can even be passed through in a parameter to other containers. WCF services - no. Views - no.
It's just a static multi-threaded event manager, there is an example of making one yourself and it's usage in this MSDN Samples project that you can play with:
- Marcado como respuesta _daedalus lunes, 20 de agosto de 2012 17:02
lunes, 20 de agosto de 2012 16:22
Thank you for your reply, but i didn't understand a thing: what do you mean with "WCF services - no. Views - no"? They can't use it?
Anyway, with Services i mean service classes in an MVVM application.
- Editado _daedalus lunes, 20 de agosto de 2012 16:29
lunes, 20 de agosto de 2012 16:33Moderador
You said "Services", I assumed you meant WCF services, which are server side, not in your client application, so they cannot "send" a message or "register" for a message.
Views use Routed Events in triggers, but cannot (to my knowledge) use the MVVMLite Messenger class in triggers or bindings.
Anywhere else in your application that can access (or be passed in a parameter) the Messenger class can use it.
lunes, 20 de agosto de 2012 17:02
Thank you again!
Can I ask you another question?
I would like to know the same thing for the IoC Container: if it can be accessed only by App.cs that instantiates it or also by other components.
If so, which components usually refer to it?
- Editado _daedalus lunes, 20 de agosto de 2012 17:11