public override void Show(MvxViewModelRequest request) { if (NavigationController == null) { // First controller called from main hamburger menu. Must have decorator: WrapInNavigationController = true base.Show(request); } else { // Subsequent controllers called from main menu or other views MvxViewController c = _rootController.CreateViewControllerFor(request) as MvxViewController; string val = ""; if (request.PresentationValues != null) { request.PresentationValues.TryGetValue("NavigationMode", out val); } if (val.Equals("Push", StringComparison.Ordinal)) { // Push new controller onto navigation stack PushViewControllerIntoStack(NavigationController, c, true); } else { // Replace stack in existing navigation controller with new controller UIViewController[] controllers = { c }; // SetViewControllers unloads all the navigation bar buttons // Don't animate to avoid visible refresh when switching root menu items NavigationController.SetViewControllers(controllers, false); NavigationController.NavigationBar.TopItem.SetRightBarButtonItems(AlertItem.GetAlertItems(), false); NavigationController.NavigationBar.TopItem.SetLeftBarButtonItem(HamburgerItem.Button, false); } } }
/// <summary> /// Not type safe version of AddFragmentViewModel<TFragmentViewModel>. /// Use AddFragmentViewModel<TFragmentViewModel>. /// </summary> /// <param name="TFragmentViewModel">IMvxViewModel which is wanted to be added.</param> /// <param name="containerViewHolder">Container: a placeholder to fragment.</param> public static void AddFragmentViewModel(this MvxViewController thisController, Type TFragmentViewModel, UIView containerViewHolder) { var viewModel = Mvx.IoCProvider.GetType().GetMethod("IoCConstruct", new Type[] { }).MakeGenericMethod(TFragmentViewModel).Invoke(Mvx.IoCProvider, null) as IMvxViewModel; UIViewController controller = thisController.CreateViewControllerFor(viewModel) as UIViewController; thisController.AddFragmentView(controller, containerViewHolder); }