IsContentPreserved performance

3 posts, 0 answers
  1. Vikas
    Vikas avatar
    64 posts
    Member since:
    May 2014

    Posted 22 Apr 2015 Link to this post

    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. 




  2. Kiril Vandov
    Kiril Vandov avatar
    323 posts

    Posted 23 Apr 2015 Link to this post

    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

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

  3. DevCraft R3 2016 release webinar banner
  4. Vikas
    Vikas avatar
    64 posts
    Member since:
    May 2014

    Posted 23 Apr 2015 in reply to Kiril Vandov Link to this post


Back to Top