Reputation: 11
I am using MvvmCross 5.6.6. I am using IMvxNavigationService for navigation. Navigation to view model of tabs from TabLayoutViewModel:
tasks.Add(NavigationService.Navigate<TabOneViewModel>());
tasks.Add(NavigationService.Navigate<TabTwoViewModel>()); tasks.Add(NavigationService.Navigate<TabThreeViewModel>());
tasks.Add(NavigationService.Navigate<TabFourViewModel>());
await Task.WhenAll(tasks);
All fragments use:
[MvxFragmentPresentation(FragmentHostViewType = typeof(DamagePanelView), FragmentContentId = Resource.Id.content_frame, AddToBackStack = true)]
How can I close (remove) all tab viewmodels (TabOneViewModel, TabTwoViewModel, TabThreeViewModel, TabFourViewModel) when I close the main view model (TabLayoutViewModel)?
Upvotes: 1
Views: 142
Reputation: 133
You can use something like this:
public virtual Task<bool> Close(IMvxViewModel viewModel)
{
var args = new NavigateEventArgs(viewModel);
OnBeforeClose(this, args);
var close = ViewDispatcher.ChangePresentation(new MvxClosePresentationHint(viewModel));
OnAfterClose(this, args);
return Task.FromResult(close);
}
Just do a for
with this function for every page you want to close in the part of your code that you want to close the main view model
Upvotes: 1