Last active
August 29, 2015 13:58
-
-
Save edsnider/10035854 to your computer and use it in GitHub Desktop.
Clearing WP back stack in MvvmCross
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace MyApp.Portable.ViewModels | |
{ | |
public class BaseViewModel : MvxViewModel | |
{ | |
protected void ShowViewModelAndClearBackStack<TViewModel>() | |
where TViewModel : BaseViewModel | |
{ | |
ShowViewModel<TViewModel>(); | |
ChangePresentation(new ClearNavBackStackHint()); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace MyApp.WP8.Views.ViewPresenters | |
{ | |
public class CustomWP8ViewPresenter : MvxPhoneViewPresenter | |
{ | |
public CustomWP8ViewPresenter (PhoneApplicationFrame rootFrame) : base(rootFrame) | |
{ } | |
public override void ChangePresentation(MvxPresentationHint hint) | |
{ | |
if (hint is ClearNavBackStackHint) | |
{ | |
while (RootFrame.BackStack.Any()) | |
{ | |
RootFrame.RemoveBackEntry(); | |
} | |
} | |
base.ChangePresentation(hint); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace MyApp.WP8 | |
{ | |
public class Setup : MvxPhoneSetup | |
{ | |
public Setup(PhoneApplicationFrame rootFrame) : base(rootFrame) | |
{ | |
} | |
protected override IMvxPhoneViewPresenter CreateViewPresenter(PhoneApplicationFrame rootFrame) | |
{ | |
var presenter = new CustomWP8ViewPresenter(rootFrame); | |
Mvx.RegisterSingleton(presenter); | |
return presenter; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment