0

I have a problem...I have MvxGridView with Menu items and with ItemClick ShowMenuCommand

Like this:

private ICommand _showMenuCommand;
        public ICommand ShowMenuCommand
        {
            get
            {
                _showMenuCommand = _showMenuCommand ?? new MvxCommand<Menu>(DoShowMenuCommand);
                return _showMenuCommand;
            }
        }

        private void DoShowMenuCommand(Menu menu)
        {
           ShowViewModel<MenuCardViewModel>(menu);
        }

Menu contains some properties like header, name, image, etc.. but contains also List menuItems. When I debug and breakpoint in DoShowMenuCommand Menu has List of menuItems but when I debug and breakpoint in MenuCardViewModel in method Init:

 public void Init(Menu menu)
        {
            // HERE..
        }

So here Menu has everything but MenuItems list is null. I dont know why... some tips why everything is here but list is null?

pnk
  • 293
  • 2
  • 14

1 Answers1

0

MvvmCross serialises complex DTO's into JSON. I'm not sure how you have implemented this but you could try it this way and see if that helps:

private void DoShowMenuCommand(Menu menu)
{
     ShowViewModel<MenuCardViewModel,Menu>(menu);
}

So the second generic is the model that you want to pass. The next step is to add the menu generic to the "MenuCardViewModel"

public class MenuCardViewModel : MvxViewModel<Menu>

This will require to implement the init method:

 protected override Task Init(Menu menu)
 {

 }

If this doesn't work i would suggest diving into why your list is not serializable/deserializable.

Marc Bruins
  • 136
  • 1
  • 9