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

IsContentPreserved performance

2 Answers 519 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
Vikas
Top achievements
Rank 1
Vikas asked on 22 Apr 2015, 06:57 PM

I am using WPF tab control and each tab item has a user control, Some of the user controls have lot of UI elements and there are lot bindings, because by default tab control load/unload each tab item when you switch tabs it is very slow, I mean there is a delay of few seconds between user clicking on a tab and tab is completely rendered.

I am planning to give RadTabcontrol a try and use iscontent preserved proerty, but before i do that i wanted to find out what are the pros/cons of using iscontent preserved, according to your documentation "For performance optimization the ControlTemplate of the RadTabControl defines a single ContentPresenter which holds only the currently selected RadTabItem's Content. "

If i use content preserved will it also prevent call to the constructor of each user control and call to loaded/unloaded event of user control when you switch tabs. 

 

Thanks

Vikas

2 Answers, 1 is accepted

Sort by
0
Kiril Vandov
Telerik team
answered on 23 Apr 2015, 01:16 PM
Hello Vikas,

The IsContentPreserved property of the RadTabControl loads the Content of its children only once (when you click item for first time) and then preserve its State by simply keeping the Content of all its Tabs. As the content is preserved the Unloaded/Loaded methods are not called after their initial loading as they stays loaded in the application. The con of that approach is that all items are loaded in the memory and your application may consume a little more memory, but this is expected as the items stays in the VisualTree and are never unloaded.

Please note that there is something specific to the TabContol's, nevertheless you are using the MS TabControl or the RadTabControl. When the TabControl is initialized it fires the Loaded event of all its TabItems as they are added to the LogicalTree and you need to be cautious if you make some heavy operation on loaded. You can easily check if you are in logical/visual loaded is fired by checking the VisualTreeHelper.GetParent if it returns null, then it is the loaded event to the LogicalTree and you can skip your calculation.

I hope this information helps. Please let us know if you need further assistance,

Kind regards,
Kiril Vandov
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Vikas
Top achievements
Rank 1
answered on 23 Apr 2015, 04:01 PM

Thanks.

Tags
TabControl
Asked by
Vikas
Top achievements
Rank 1
Answers by
Kiril Vandov
Telerik team
Vikas
Top achievements
Rank 1
Share this question
or