This is a migrated thread and some comments may be shown as answers.

VisualStates and TabControl

3 Answers 62 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
P
Top achievements
Rank 1
P asked on 29 Feb 2012, 05:31 PM
Hi,

Does the RadTabControl not work with VisualStates?

I have several tabs with different content in them and using Expression Blend modified a Visual State so that on one of the RadTabItems a child buttons visibility is set to collapsed in order to hide it.

I find that this can cause exceptions to be thrown in Expression Blend when I move to a different tab. Within the application I am using property triggers and GoToStateAction class to change to the visual state. When this happens I get a first chance exception - InvalidOperationException : 'Cannot Resolve TargetName btnSaveCertificates'.

Looking through the telerik documentation it seems that the reason for this is that as the user moves between tabs it is only the active tab whose content is displayed and part of the Visual Tree because only a single content presenter is being used by the RadTabControl. Hence even though the button to be hidden is visible within the xaml, it is only part of the Visual Tree when its parent Tab is active.

I have looked at the IsContentPreserved property of the RadTabControl setting it to true, but when I run the application the tabs contents are blank. Is the idea behind this property that all of the TabItems content is loaded into the VisualTree so that it can be accessible by VisualStates?

Please advise.

Cheers
pb

3 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 02 Mar 2012, 02:28 PM
Hi,

IsContentPreserved property provides ContentPresenter for every TabItem content (more precisely, every previously selected  item). Thus when you select particular item its content will be inserted into the visual tree via dedicated content presenter. When next item is selected, its content will be inserted dynamically into the visual tree again via dedicated content presenter and the previously visible content will be collapsed.

So if all tab items have been selected, their content will be part of the visual tree. If item has not yet been selected its content won't be in the visual tree.

Hope this helps.

Regards,
Hristo
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
P
Top achievements
Rank 1
answered on 02 Mar 2012, 03:00 PM
Hi Hristo,

Thanks for the reply.

So would the best option be to programmatically select each tab in turn to force the control to load all the content. Perhaps doing this once in the controls LayoutUpdated event?

Kind Regards
pb
0
Hristo
Telerik team
answered on 06 Mar 2012, 09:59 AM
Hi,

What you are suggesting is to select every item when TabControl is initialized and rendered. Doing this on LayoutUpdated sounds reasonable. However, you should keep in mind that this will degrade the performance during initial load.
My personal advise would be to use data binding and change the visibility in you view model. When selecting new tab its content (button) visibility shall be retrieved from the view model via binding.
If you are limited and could not use binding, selecting programmatically every tab is the approach you should employ.

All the best,
Hristo
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
TabControl
Asked by
P
Top achievements
Rank 1
Answers by
Hristo
Telerik team
P
Top achievements
Rank 1
Share this question
or