You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi Miroiu.
In the TabControl, static TabItem and dynamic TabItem, when the Tab page is switched, all nodes in the dynamic TabItem seem to be initialized and re-rendered, so it will take more time to complete the Tab page switch (the number of nodes in the test is 150/page, and the more nodes, the more obvious the time difference).
Is this a problem with the processing mechanism of TabControl itself? Can the processing logic of dynamic TabItem switching be the same as that of static TabItem?
Thanks for any replies and suggestions.
Hi @LaiHT1211 , this is a known issue with the default TabControl implementation. When binding to the ItemsSource property, the TabControl discards visuals for unselected tabs, causing them to be rebuilt entirely when re-selected. This can be costly, especially for complex templates.
Unfortunately, if you're using a typical MVVM approach with a binding on the ItemsSource property of the TabControl, the entire tree must be rebuilt each time a tab item is selected. This is usually a very expensive operation.
The discarding of items is really only a problem when using a TabControl in ItemsSource mode. In Direct mode, the visuals will still be unloaded from the tree, but they won't be discarded.
However, the performance hit may also be caused by the complexity of the DataTemplate of the node, but that's only for the initial load. Try replacing the DataTemplate with a simple control like this to see the difference:
<DataTemplateDataType="{x:Type local:ExpandoOperationViewModel}">
<TextBlockText="This is a node" />
</DataTemplate>
Hi Miroiu.
In the TabControl, static TabItem and dynamic TabItem, when the Tab page is switched, all nodes in the dynamic TabItem seem to be initialized and re-rendered, so it will take more time to complete the Tab page switch (the number of nodes in the test is 150/page, and the more nodes, the more obvious the time difference).
Is this a problem with the processing mechanism of TabControl itself? Can the processing logic of dynamic TabItem switching be the same as that of static TabItem?
Thanks for any replies and suggestions.
Static tab item video
https://github.com/user-attachments/assets/575caa62-49b5-4de5-90bb-0353df32fac9
Dynamic tab item video
https://github.com/user-attachments/assets/28594096-452d-443c-be26-ab9a5456f471
The text was updated successfully, but these errors were encountered: