My WPF application is organized as a TabControl with each tab containing a different screen.
One TabItem is bound to data that takes a little while to load. Since this TabItem represents a screen that users may only rarely use, I would like to not load the data until the user selects the tab.
How can I do this?
Tab control works two ways,
Using 2nd method is little complicated, but at runtime it will certainly reduce the resources it is using, but at time of switching tabs, it may be little slower for a while.
You have to create custom data class as following
And you must create list or array of TabItemData and you must set TabControl’s items source to list/array of TabItemData.
Then create ItemTemplate of TabControl as data template binding “Header” property.
Then create create ContentTemplate of TabControl as data template containing ContentControl with ContentTemplate of Resource key found in ResourceKey property.