Edit this page

Configure the RadTabControl when Bound to a Collection of Visual Elements

The RadTabControl is designed to allow databinding scenarios out-of-the-box. However, by default the control implementation expects the ItemsSource collection to be a business collection where no visual elements are defined.

Basically in databinding scenarios the control allows you to choose whether you want to use one ContentPresenter for all RadTabItems or use multiple ContentPresenters - one for each RadTabItem, in order to keep each item's state while changing the selection (read more).

If you set the RadTabControl.IsContentPreserved property to True, then each RadTabItem will have a ContentTemplate. In this case you will be able to bind the control to a collection of visual elements as well.

If you, on the other hand, use the default implementation of the control in which the RadTabControl.IsContentPreserved property is set to False, there will be one ContentPresenter for all RadTabItems. Then when the selection is changed, the ContentPresenter.ControlTemplate will be reapplied over and over for each newly selected item. This will raise an exception when your business objects contain visual elements since you cannot place the same visual element twice in the visual tree.

SupressSelectedContentTemplateReapplying property

In order to get over this limitation, the RadTabControl exposes a property that allows you to control its internal logic in such scenarios - SupressSelectedContentTemplateReapplying. By default the SupressSelectedContentTemplateReapplying property is set to False along with the IsContentPreserved property. That means that the default implementation of the RadTabControl keeps one ContentPresenter for all its Items and reapplies its ContentPresenter.ContentTemplate on each selection change.

But if you set the SupressSelectedContentTemplateReapplying property to True, then the RadTabControl will still have one ContentPresenter but it won't reset its ContentTemplate whenever the selection is changed and this will allow you to place visual elements in the RadTabControl.ItemsSource collection.

Please keep in mind that if you set the SupressSelectedContentTemplateReapplying property to True the same RadTabControl.ContentTemplate is applied to all RadTabItems. And if the ControlTemplate elements aren't databound, the same values will be displayed in all RadTabItems.