I'm trying to pass objects across view models in MVVM Cross. Here's the code for the VM that I'm passing from:
private void CallVM2()
{
MyObj newObj = new Myobj();
IMyService myService = new MyService();
Dictionary<string, object> p = new Dictionary<string, object>()
{
{"MyObj", newObj},
{"MyService", myService}
};
ShowViewModel<ViewModel2>(p);
}
And here's the code for ViewModel2:
public void Init(Dictionary<string, object> p)
{
}
Okay - so I tried InitFromBundle
too, but it appears that I need Init
. I can't work out how or why this gets called, but it does. What it doesn't do is populate the parameters.
So, my questions are:
- How and why is
init
called by the MVVM framework (assuming that is the correct method)? - Should I be using
InitFromBundle
and if not, what is that for? - Why does my code not pass through a dictionary of objects to Init, and how can I make it?