ios - MvvmCross: How to use FlyoutNavigation component with MvvmCross -
is there example on how use mvvmcross flyoutnavigation component xamarin.
i getting error when tried set viewcontrollers using menu views mainnavigationviewmodel. error got "system.reflection.targetinvocationexception: exception has been thrown target of invocation."
here sample code:
public class mainnavigationviewmodel : mvxviewmodel { public mainnavigationviewmodel() { menuone = new menuoneviewmodel(); } private menuone _menuone; public menuoneviewmodel menuone { { return _menuone; } set { _menuone = value; raisepropertychanged(() => menuone); } } } [register("mainnavigationview")] public sealed class mainnavigationview : mvxviewcontroller { protected mainnavigationviewmodel mainnavviewmodel { { return base.viewmodel mainnavigationviewmodel; } } public mainnavigationview() { viewdidload(); } public override void viewwillappear(bool animated) { base.viewwillappear(animated); navigationcontroller.navigationbarhidden = true; } public override void viewdidload() { base.viewdidload(); if (viewmodel == null) return; var flyoutnavigationcontroller = new flyoutnavigationcontroller(); var menuviewroot = new rootelement(null); var menuitems = new list<stringelement>() { new stringelement("menu one") }; var menusection = new section("main menu") { menuitems }; menuviewroot.add(menusection); flyoutnavigationcontroller.navigationroot = menuviewroot; var viewcontrollers = new uiviewcontroller[1]; viewcontrollers[0] = createmenuitemcontroller(mainnavviewmodel.mainone); flyoutnavigationcontroller.viewcontrollers = viewcontrollers; flyoutnavigationcontroller.view.frame = uiscreen.mainscreen.bounds; flyoutnavigationcontroller.togglemenu(); add(flyoutnavigationcontroller.view); } private uiviewcontroller createmenuitemcontroller(imvxviewmodel viewmodel) { var controller = new uinavigationcontroller(); var screen = this.createviewcontrollerfor(viewmodel) uiviewcontroller; controller.pushviewcontroller(screen, false); return controller; } }
try example https://github.com/fcaico/mvxslidingpanels.touch based on fork of component
Comments
Post a Comment