RegionManager and TabControl - how does it work?

Topics: Prism v4 - Silverlight 4
Dec 7, 2011 at 9:37 PM

I implemented my own TabControl (based on TabControl). I also created IMPLICIT style for TabItem.

Everything works great before I start using Region with this TabControl. Tabs I add via XAML look properly as I styled them. But tabs region manager inserts DO NOT. They look stock. That means, when RegionManager creates tab - it somehow assigns it different style.

I tried to make this tyle explicit and assign it to TabControlRegionAdapter.ItemContainerStyle 

This Works, but I'd rather have RabControlRegionAdapter to pick up my implicit style. Is there any way to make it work right?

Dec 12, 2011 at 8:46 PM


Based on my understanding, setting the TabControlRegionAdapter.ItemContainerStyle property in the corresponding TabControl is part of the normal behavior of the TabControlRegionAdapter. As it can be seen in the PrepareContainerForItem method of the TabControlRegionSyncBehavior behavior, when the item is "prepared" to be added in the TabControl, its Style property is set to the value returned by the GetItemContainerStyle method of the TabControlRegionAdapter, which simply returns the value of the ItemContainerStyle property of a specific DependencyObject (in this case, the TabControl). This is why, when the ItemContainerStyle property is set in your TabControl, the style is applied properly.

If you do not wish to use this property, you could create your own custom region adapter (based on the TabControlRegionAdapter) that obtains the required style through other means (for example, using the other properties of your TabControl) and register that behavior overriding the ConfigureRegionAdapterMappings method in your bootstrapper.

I hope you find this useful,

Damian Cherubini