Skip to content

Instantly share code, notes, and snippets.

@dellis1972
Forked from gshackles/gist:5735595
Created January 13, 2014 09:14
Show Gist options
  • Save dellis1972/8396970 to your computer and use it in GitHub Desktop.
Save dellis1972/8396970 to your computer and use it in GitHub Desktop.
public abstract class ViewModelBase : MvxViewModel
{
protected void ClearStackAndShowViewModel<TViewModel>()
where TViewModel : ViewModelBase
{
var presentationBundle = new MvxBundle(new Dictionary<string, string> { { PresentationBundleFlagKeys.ClearStack, "" } });
ShowViewModel<TViewModel>(presentationBundle: presentationBundle);
}
}
public static class PresentationBundleFlagKeys
{
public const string ClearStack = "__CLEAR_STACK__";
}
public class SlidingMenuViewPresenter : MvxModalNavSupportTouchViewPresenter
{
public override void Show(MvxViewModelRequest request)
{
if (request.PresentationValues != null)
{
if (request.PresentationValues.ContainsKey(PresentationBundleFlagKeys.ClearStack))
{
var nextViewController = (UIViewController)ViewCreator.CreateView(request);
if (MasterNavigationController.TopViewController.GetType() != nextViewController.GetType())
{
MasterNavigationController.PopToRootViewController(false);
MasterNavigationController.PushViewController(nextViewController, false);
}
return;
}
}
base.Show(request);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment