Click here to Skip to main content
15,902,198 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Weak reference keeping objects alive with Mediator Pin
_Maxxx_13-Mar-11 1:39
professional_Maxxx_13-Mar-11 1:39 
GeneralRe: Weak reference keeping objects alive with Mediator Pin
_Maxxx_13-Mar-11 15:10
professional_Maxxx_13-Mar-11 15:10 
QuestionA basic KIOSK application using WPF/ Silverlight Pin
Member 365700710-Mar-11 20:50
Member 365700710-Mar-11 20:50 
AnswerRe: A basic KIOSK application using WPF/ Silverlight Pin
Abhinav S10-Mar-11 21:24
Abhinav S10-Mar-11 21:24 
AnswerRe: A basic KIOSK application using WPF/ Silverlight Pin
Richard MacCutchan10-Mar-11 22:31
mveRichard MacCutchan10-Mar-11 22:31 
GeneralRe: A basic KIOSK application using WPF/ Silverlight Pin
Member 365700710-Mar-11 23:02
Member 365700710-Mar-11 23:02 
GeneralRe: A basic KIOSK application using WPF/ Silverlight Pin
Richard MacCutchan10-Mar-11 23:48
mveRichard MacCutchan10-Mar-11 23:48 
QuestionMVVM Messenger / Mediator question Pin
_Maxxx_9-Mar-11 15:29
professional_Maxxx_9-Mar-11 15:29 
I've been using the Mediator pattern for a while in MVVM - specifically using the MVVMFoundation implementation mostly.

So this pattern allows you top broadcast a message that can be subscribed to by one or more classes (usually ViewModels) and handled by them.

What I am trying to do at the moment is extend this pattern as follows (an example is worth 1K words)

Customer Lookup allows user to select a customer, and will open an 'Edit' window for that customer. The window is not opened modally.

The user, then, can select the same customer again for editing (because the user is daft).

So I would like the Customer Lookup Vm to send out a 'This customer has been selected' message, to which the Customer Edit VM would subscribe.

If , as a Customer Edit VM I receive the message, and I am currently editing that same customer, then I can take some action (show a 'Silly User' message for example).
If I receive the message and I am not editing that same customer, I can ignore the message.

But if the message is sent and ignored by all VMs out there (because there isn't one editing this particular customer) then I need to get a new Customer Edit VM created to go edit this customer.

Now, I'd like to do this reasonably generically, so I started looking at the Messanger class, to see if I can't add to it, to enable 'IsHandled" type properties. And it works well.

Except!

My Customer Lookup is the first VM instantiated, and so is the first Vm to register to receive the message - and so handles it immediately - without giving he other ViewModels a chance!

Obviously, sending the messages is handled in a loop - so I could reverse the order - but it may not be the last instantiated View Model that I want to handle a message.
Or I could add a 'priority' to the message registration process - and sort the responses in priority order, so that my Edit VMs see the message first.
Or, I could change the messaging into a two-step process - the first stage asks who can handle the message, and the second stage decides who to give the message to.

I guess what I'd like is to hear some discussion on this. Have you done something similar (is there some code out there I can steal look at for inspiration? Have you overcome similar problems some other way?
___________________________________________
.\\axxx
(That's an 'M')

AnswerRe: MVVM Messenger / Mediator question Pin
SledgeHammer019-Mar-11 17:21
SledgeHammer019-Mar-11 17:21 
AnswerRe: MVVM Messenger / Mediator question Pin
Pete O'Hanlon9-Mar-11 20:06
mvePete O'Hanlon9-Mar-11 20:06 
GeneralRe: MVVM Messenger / Mediator question Pin
_Maxxx_9-Mar-11 21:25
professional_Maxxx_9-Mar-11 21:25 
GeneralRe: MVVM Messenger / Mediator question Pin
Pete O'Hanlon9-Mar-11 21:33
mvePete O'Hanlon9-Mar-11 21:33 
GeneralRe: MVVM Messenger / Mediator question Pin
_Maxxx_9-Mar-11 22:57
professional_Maxxx_9-Mar-11 22:57 
GeneralRe: MVVM Messenger / Mediator question Pin
Pete O'Hanlon9-Mar-11 23:12
mvePete O'Hanlon9-Mar-11 23:12 
GeneralRe: MVVM Messenger / Mediator question Pin
_Maxxx_9-Mar-11 23:45
professional_Maxxx_9-Mar-11 23:45 
GeneralRe: MVVM Messenger / Mediator question Pin
Pete O'Hanlon10-Mar-11 0:14
mvePete O'Hanlon10-Mar-11 0:14 
GeneralRe: MVVM Messenger / Mediator question Pin
_Maxxx_10-Mar-11 1:00
professional_Maxxx_10-Mar-11 1:00 
GeneralRe: MVVM Messenger / Mediator question Pin
Pete O'Hanlon10-Mar-11 1:43
mvePete O'Hanlon10-Mar-11 1:43 
GeneralRe: MVVM Messenger / Mediator question Pin
_Maxxx_10-Mar-11 2:22
professional_Maxxx_10-Mar-11 2:22 
GeneralRe: MVVM Messenger / Mediator question Pin
Pete O'Hanlon10-Mar-11 2:37
mvePete O'Hanlon10-Mar-11 2:37 
GeneralRe: MVVM Messenger / Mediator question Pin
Pete O'Hanlon9-Mar-11 22:38
mvePete O'Hanlon9-Mar-11 22:38 
GeneralRe: MVVM Messenger / Mediator question Pin
_Maxxx_9-Mar-11 22:58
professional_Maxxx_9-Mar-11 22:58 
QuestionMake silverlight app on page a "singleton" Pin
dbrenth9-Mar-11 10:50
dbrenth9-Mar-11 10:50 
AnswerRe: Make silverlight app on page a "singleton" Pin
Mycroft Holmes9-Mar-11 11:50
professionalMycroft Holmes9-Mar-11 11:50 
GeneralRe: Make silverlight app on page a "singleton" Pin
AspDotNetDev9-Mar-11 12:33
protectorAspDotNetDev9-Mar-11 12:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.