1
votes

i'm seeing some weirdness in my Windows Phone app with MVVMCross.

I use ShowViewModel<MyViewModel>(); to load a new view on a command being executed.

I've changed that to:

ShowViewModel<MyViewModel>(new { First = "Hello", Second = "World", Answer = 42 });

But Init isn't being called in the MyViewModel, MyViewModel inherits from another class that in turn inherits from a MvxViewModel, I've even changed both view models to inherit directly from MvxViewModel.

If i used:

Mvx.Resolve<IMvxViewModelLoader>().LoadViewModel(MvxViewModelRequest<MyViewModel>.GetDefaultRequest(), null);

Init get's called, same for the InitFromBundle, I passed a bundle containing that test object but I didn't get the values passed through.

Init method just looks like this:

public void Init(string First, string Second, int Answer)

I'm totally confused, setup, app.cs all look like the navigation example, any ideas what I might have forgot?

Windows 8.1, VS 2013, Hot Tuna, Windows phone 8.


Init methods:

public void Init()
{
}

public void Init(string First, string Second, int Answer)
{
    // use the values
    var meh = "";
    Mvx.Trace("Init called in {0}", GetType().Name);
}

protected override void InitFromBundle(IMvxBundle bundle)
{

}
1
Is there any trace telling you what might be failing?Stuart
none, just says the view model loaded, anything I can do to make it more verbose?LiquidTrAcER
Literally just seeing mvx:Diagnostc: 7.54 Showing ViewModel MyVewModel, no errors, executes ShowViewModel with the object fine, it just never seems to call Init either with an empty constructor, with a a constructor that matches the object passed in ShowViewModel or InitFromBundle.LiquidTrAcER
I assumed you were seeing github.com/MvvmCross/MvvmCross/blob/v3.1/Cirrious/… - but if you aren't setting that exception or any trace then I don't know.Stuart
No, I didn't see that at all.LiquidTrAcER

1 Answers

0
votes

You should use ShowViewModel<NameOfViewModelClass>(new { First = "Hello", Second = "World", Answer = 42 }); instead