コード例 #1
0
        private void ExcuteSendMsh()
        {
            NotificationMessage nm = new NotificationMessage(this, String.Format("发送消息:{0}", DateTime.Now));

            //获取已存在的Messenger实例
            GalaSoft.MvvmLight.Messaging.Messenger myMessenger = SimpleIoc.Default.GetInstance <GalaSoft.MvvmLight.Messaging.Messenger>(MessengerTag);
            //消息发送
            myMessenger.Send <NotificationMessage>(nm);
        }
コード例 #2
0
        private void Init()
        {
            try
            {
                messenger = SimpleIoc.Default.GetInstance <GalaSoft.MvvmLight.Messaging.Messenger>(MessengerTag);
            }
            catch (Exception ex)
            {
                //构造函数
                messenger = new GalaSoft.MvvmLight.Messaging.Messenger();

                //注入一个Key为MyMessenger的Messenger对象
                SimpleIoc.Default.Register(() => messenger, MessengerTag);
            }
        }