开发者

MVVM Light Messaging Issue

开发者 https://www.devze.com 2023-01-26 02:42 出处:网络
I am facing with series of issues while using MVVMLight. One of them is passing non-string messages across the application.

I am facing with series of issues while using MVVMLight. One of them is passing non-string messages across the application. This is the message type I am passing -

 public class NameValue
    {
        public NameValue()
        {
        }
        public string Name { get; set; }
        public string Value { get; set; }
    }

in the View1

 Messenger.Default.Send<NameValue>(nv, "Message1");

in the ViewModel2

Messenger.Default.Register<NameValue>(this, "Message1", OnMessageSent);

 private void OnMessageSent(NameValue nv)
        {
         }

When I pass a message using Messender.Default from a View to another ViewModel it works when the message type is string but not when message type is 'NameValue'.

Please let me know if someone else is facing the same problem or there is some thing w开发者_运维百科rong in the implementation.


I was able to resolve this issue by debugging the SL4 source code uploaded on Friday.

The issue was in the code where the message was being registered for listening different 'type' of messages with same name.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号