MvvmCross does not do one ViewModel to n Views. Only 1:1 relationships are allowed.
There are various ways to tackle your problem.
1.
Pass along an object in ShowViewModel or the new NavigationService which describes your result from ICommand. For this to work, you need to wait navigating until your request is done:
var result = await GetSomeData();
ShowViewModel<ViewModelB>(new { status = Status, number = SomeNumber });
Then in ViewModelB:
public void Init(string status, string number)
{
Status = status;
Number = number;
}
Then have props for Status and Number in that ViewModel.
2.
Have a Service that you share between your ViewModels and have it keep the state and take care of your rest calls:
public class MyService : IMyService
{
public string Status {get; set;}
public string Number {get; set;}
public async Task DoStuff()
{
}
}
Then in ViewModelA ctor would be:
public ViewModelA(IMyService service)
In your Command:
public async void something()
{
await _service.DoSomething();
ShowViewModel<ViewModelB>();
}
Ctor in ViewModelB would be similar to ViewModelA and just populate whatever props or have the props directly reflect what is in service like:
public string Status => _service.Status;
These are just two ways of solving this problem.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…