Using Interaction request service in tab control

Topics: Prism v4 - Silverlight 4
Nov 24, 2010 at 4:24 AM


I have the following setup

  • Shell
    • MainRegion
      • ModuleA
        • ModuleAView
          • Tab control

Assume the tab control has 3 tabs in it with each tabs content being a view with its own view model. Each of the 3 tabs have a edit mode. Now when a user edits something in tab 1 and then clicks on tab 2 without saving, I want to alert the user with a confirmation message saying "You have unsaved changes. Do you wish to continue to navigate?" using a InteractionRequest.

As far as I understand the IConfirmNavigationRequest interface handles this. But its ConfirmNavigationRequest gets called only when the RegionManager is attempting to switch views within a region. i.e. say when it tries to navigate away from ModuleA to ModuleB in the MainRegion. But my scenario above is not the case. In my case the ModuleAView remains in the MainRegion, but its a navigation between the tabs in the view.

How should I handle this? Do I need to create TabRegionAdapter instead? If yes then can you post and example demonstrating the same?


Nov 24, 2010 at 2:27 PM


Based on my understanding, you need to detect when a view has undergone changes. Now, when a user switches between views, you need to prompt a confirmation dialog. First of all, it does not seem necessary to create a custom Region Adapter for achieving this, since Prism has already provided a region adapter for the Silverlight TabControl.

That said, another user with a similar scenario has just been answered yesterday, so I think that you can find the following forum thread interesting: TabControlRegionAdapter: how to confirm tab switching

Hope this helps.

Fernando Antivero

Nov 26, 2010 at 2:20 AM

Thanks Fernando.

I'll have a go and let you know if I get stuck anywhere.