Reputation: 65
I have an aplication with three regions. Region A is a navigation area to hold navigation items for modules in the app. Regions B and C are content areas for the modules. I also have two Modules Module1 and Module2 which each have a Navigation Item Control loaded into Region A. Region A contains NavigationItemMod1Control and NavigationItemMod2Control.
NavigationItemMod1Control is bound to a command which loads view1B into region B and view1C into region C (NavigationItemMod2Control has a similar command). Command execute method shown below:
public void Execute(object parameter)
{
// Show View 1B
var view1BUri = new Uri(Module1RegionNames.ViewBControl, UriKind.Relative);
regionManager.RequestNavigate(RegionNames.ViewBArea, view1BUri );
// Show View 1C
var view1CUri = new Uri(Module1RegionNames.ViewCControl, UriKind.Relative);
regionManager.RequestNavigate(RegionNames.ViewCArea, view1CUri );
}
When I click on NavigationItemMod2Control, I want to confirm navigation before loading either view 2B or view 2C into respective regions.
I've successfully implemented IConfirmNavigationRequest on the viewmodel for View1B in Module 1 , but this only controls navigation for region B. If the user cancels the navigation request, region B correctly stays as View1B, but View2C is loaded into region C.
Any suggestions on how to confirm navigation once for both regions?
Upvotes: 3
Views: 1337
Reputation: 7467
The request navigate comes with an overload that supports a callback:
var navigationParameters = new NavigationParameters();
navigationParameters.Add("RelatieId", _CurrentRelatie.RelatieId);
regionManager.RequestNavigate("RelatieDetailRegion",
new Uri("RelatieDetail", UriKind.Relative), NavigationCallback, navigationParameters);
void NavigationCallback(NavigationResult nr)
{
_logger.Log("NavigationCallback", Category.Info, Priority.Medium);
if (nr.Result.Value == true)
{
//navigate region C, so this is your code
var view1CUri = new Uri(Module1RegionNames.ViewCControl, UriKind.Relative);
regionManager.RequestNavigate(RegionNames.ViewCArea, view1CUri );
}
}
this is based on a code snippet of mine, you'll have to tweak a little, for instance not to use the navigationparameters, which you don't use.
Upvotes: 1