Mar 14, 2013 at 7:58 AM
Edited Mar 14, 2013 at 8:03 AM
I'm not sure if I can use this in my case or maybe I didn't understand it completely but I try to describe my problem better (let me know if your suggestion should do the trick):
The TabItem in the TabRegion is DashboardTabView which has a ContentControl. Now, when I add the tabitem to TabRegion (using navigation) I also navigate another view (MissingMeasurementView) to it's TabContentRegion using scoped region manager:
// Navigate to DashboardTabView with a title for the Tab item
new Uri("DashboardTabView?createRegionManagerScope=true&title=" + TitleText, UriKind.Relative),
// Get scoped region manager and use it to navigate to sub view
var myRegionManager = result.ExtractRegionManager();
new Uri("MissingMeasurementView?view=1", UriKind.Relative)
After the Tab is opened I can see the MissingMeasurementView and from that view I can navigate to next view, for example, View2. And from View2 I can navigate back to MissingMeasurementView using Shell's navigation back button. This is all working nicely. I
publish current navigationContext.NavigationService on each OnNavigatedTo event so that my application's Shell can offer Back/Forward navigation buttons.
public override void OnNavigatedTo(NavigationContext navigationContext)
// get navigation service
NavigationService = navigationContext.NavigationService;
// Send event with Navigation service to handle back/forward navigation under this Tab
var dashboardEvent = this.eventAggregator.GetEvent<DashboardOpenTabEvent>();
DashboardTabOpenParams eventParams = new DashboardTabOpenParams();
eventParams.NavigationService = NavigationService;
Problem that I'm facing with this is that if user changes selected Tab and creates another instance of this same Tab (DashboardTabView) the Shell does not get old Tab's navigation service anymore because OnNavigatedTo does not seem to trigger when I change
selected Tab but only when I create the Tab and navigate inside the Tab. So basically navigation works only for the most recently created Tab.
That is why I wanted to somehow know which Tab is open and get that Tab's navigation service published via EventAggregator. One way that I came up with was to use TabItem's IsSelected property and bind it to a property in DashboardTabViewModel. In DashboardTabViewModel
I could then send navigation service event in property's Setter but DashboardTabViewModel does not know about scoped region's navigation service. It only knows about TabControl's TabRegion navigation service which is not the one I want to use. I want to use
TabContentRegion's navigation service which, I believe, is not available in DashboardTabViewModel.
So I would need to get scoped region's navigation service in DashboardTabViewModel to go with this IsSelected property binding approach.
Hope this makes more clear what I'm trying to accomplish.