android - NullReferenceException in MvvmCross Messenger -


this code in viewmodel

public icommand gotocartcommand{         get{              return new mvxcommand (() => {                                   var cartviewmodel = mvx.resolve<cartviewmodel>();                 if (cartviewmodel != null)                 {                     cartviewmodel.cartlist.add(new cartitemviewmodel() { name = name, id = id, unitprice = double.parse(price), quantity = 1, description = description, image = image });                 }                 cartlistcount = cartviewmodel.cartlist.count;                 var messanger = mvx.resolve<imvxmessenger>();                 var message = new mymessage(this,"product has been added",cartlistcount);                 messanger.publish(message);             });         }     }   public class mymessage : mvxmessage {     public int cartlist_count{ get; set;}        public string message{ get; set;}      public mymessage(object sender,string _message,int _cartlist_count) : base(sender) {          this.message = _message;         this.cartlist_count = _cartlist_count;     } } 

this code in view :

  var messenger = mvx.resolve<imvxmessenger>(); _token = messenger.subscribe<mymessage>(oninputisneeded,mvxreference.strong);   private void oninputisneeded(mymessage _message) {         toast.maketext (this.activity,_message.message, toastlength.short).show(); } 

my problem here when comeback view after going next view oninputisneeded method called 2 times. , when go view , when again come view , click button nullreferenceexception.

what solution?

what meaning of this: nothing registered messages of type mvxsubscriberchangemessage

how register mvxsubscriberchangemessage?


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -