Reffering to N=9 what I would like to do is in place of ILocationService I have my own INavigationService and a Navigation Service class.
public class NavigationService :INavigationService
{
private readonly IMvxMessenger _navigator;
public NavigationService(IMvxMessenger navigator)
{
_navigator = navigator;
}
public void OnNavigation(PurchasesDataEntryViewModel vm)
{
var navigationMessage = new NavigationMessage(this,vm);
_navigator.Publish(navigationMessage);
}
}
And this is my Messenger class:
public class NavigationMessage : MvxMessage
{
public string ShopID { private set; get; }
public int TotalStock { private set; get; }
public int TotalPurchases { private set; get; }
public int Stock1 { private set; get; }
public int Stock2 { private set; get; }
public int Stock3 { private set; get; }
public int Purch1 { private set; get; }
public int Purch2 { private set; get; }
public int Purch3 { private set; get; }
public string Name { private set; get; }
public string CPrice { private set; get; }
public int CSales { private set; get; }
public string BrandID { private set; get; }
public string CatID { private set; get; }
public int LadgePur { private set; get; }
public decimal LPrice { private set; get; }
public int LPurch { private set; get; }
public int LSales { private set; get; }
public int LStock { private set; get; }
public int LStock1 { private set; get; }
public string MeasureID { private set; get; }
public NavigationMessage(object sender, PurchasesDataEntryViewModel vm)
: base(sender)
{
ShopID = vm.ShopID;
TotalStock = vm.TotalStock;
TotalPurchases = vm.TotalPurchases;
Stock1 = vm.Stock1;
Stock2 = vm.Stock2;
Stock3 = vm.Stock3;
//Purch1 = vm.Purch1;
//Purch2 = vm.Purch2;
//Purch3 = vm.Purch3;
Name = vm.Name;
CPrice = vm.CPrice;
// CSales = vm.CSales;
BrandID = vm.BrandID;
CatID = vm.CatID;
LadgePur = vm.LadgePur;
LPrice = vm.LPrice;
LPurch = vm.LPurch;
LSales = vm.LSales;
LStock = vm.LStock;
LStock1 = vm.LStock1;
MeasureID = vm.MeasureID;
}
What I want to achieve is to send the above values to my subscriber PurchasesDataEntryViewModel
private readonly IDataService _dataService;
private readonly MvxSubscriptionToken _token;
public PurchasesDataEntryViewModel(IDataService dataService,INavigationService service, IMvxMessenger navigator)
{
_dataService = dataService;
_token = navigator.Subscribe<NavigationMessage>(OnNavigationMessage);
}
private void OnNavigationMessage(NavigationMessage navigationMessage)
{
ShopID = navigationMessage.ShopID;
.
.
.
}
}
I cannot make it to work. I need to understand the interaction and lifecycle of Publish/Subscribe. How do the two viewmodels will understand how to communicate. I need somehow to tell my Messenger service that I want to send parameters from ViewModel A to ViewModel B through the messenger class. This is the first time I use the plugin so forgive me for the stupid questions.
i cannot make it to workmean? An exception? A crash? Some trace? Please provide more detail. - Stuart