Prism 5: How do I know which tab in "TabRegion" is currently selected?

May 22, 2014 at 6:03 PM
Hello,

I implemented a Tab Region which works fine. The problem is that I have a separate menu region and the same menu command in the menu region should work differently depending on which tab in the TabControl is currently selected. I implemented IActiveAware in the view classes in the tab region. But all of the views' IsActive are set to true when the region.Activate() is called (I'm using view injection because I need to dynamically add tabs) and I cannot tell which tab is currently selected.

How do I know which tab is currently selected?

Thanks,
May 22, 2014 at 7:32 PM
Hi,

The following discussion threads mey help you:
Each Region has an ActiveViews property, which returns to you a list of all the Views in the region that are currently active. The scenario you described would use a Region for the TabControl. Therefore, you would have only one activeView.

Then, you can resolve the returned view and perform the desired logic.

Regards.
Gabriel Ostrowsky.
https://blog.southworks.net/gostrowsky
May 23, 2014 at 2:58 PM
Hi Gabriel,

Thanks for your response. I used region.ActiveViews.FirstOrDefault(). But it didn't work. The setter for the IsActive property was not called either when I clicked different tabs. However, I have finally found why those didn't work - I was using Telerik's RadTabControl, rather than the standard TabControl. I blindly assumed that the Telerik control simply inherits the standard one. But obviously it does not. When I replaced it with the standard one, everything worked.

Thank you for your help, anyways.

Tetsu