Messenger Send Problem

May 15, 2015 at 4:14 PM
Edited May 15, 2015 at 4:26 PM
Hi Guys

I'm having a problem using the Messenger while Navigating.

As described here I am not able to use the OnNavigatedTo event.

Instead i now tried to use the messenger but it doesnt seem two work for me either.

I implemented a class:
public class CreateLogBookMessage : GenericMessage<Machine>
    {
        public CreateLogBookMessage(object sender, Machine selectedMachine)
            : base(sender,selectedMachine)
        {

        }
    }
and then registerted for it in my ViewModel:
Messenger.Default.Register<CreateLogBookMessage>(
                this, LogBookMessage =>
                {
                    this.SelectedMachine = LogBookMessage.Content;
                });
Finally i navigated in my RelayCommand:
_navigationService.NavigateTo(ViewModelLocator.LogBookEntryURL);


                            var createLogBookMessage = new CreateLogBookMessage(this,  this.SelectedMachine);
                            Messenger.Default.Send(createLogBookMessage);
I set a breakpoint on the Property in the receiving VM but it doesnt seem to get a message at all.

Any ideas? If you could solve the question on stackoverflow, it would help me, too :)

Edit:
I found out that the receiving VM constructor is called AFTER the Message is sent. How can i register the message so that the rec. VM will listen to it once constructed?

Thanks Julian