tags:

views:

26

answers:

1

I have a TabControl in WPF.

When I remove a certain TabItem from the collection, depending on the content displayed in the TabItem, there can be a noticeable two or three second delay, before the TabItem is removed.

Any suggestions on how to improve this so that the delay is not noticeable?

Also - there appears to be a memory leak - as the memory retained by the WPF application does not decrease when the TabItem is removed. Anybody experience similar behavior?

Thanks!

Chris

A: 

Do you get the same delay when using blank tab items? And do you get the same delay when switching tabs?

WPF unloads the VisualTree of the tabs that are not currently being displayed. If you switch tabs, it unloads the one you just had and reloads the new tab. Depending on how complex your TabItems are, this could be the cause of your delay.

I ran into the same problem and found an alternative here. It basically stores the ContextPresenter of tab items in memory, and loads those up instead of redrawing the VisualTree

Rachel