Saurabh. When you install a Template, usually a DataTemplate, ControlTemplate, etc., the visual elements inside these templates are reused in WPF with the concept of user interface virtualization. TabControl usually only displays one item at a time, so it does not create a new visual item for each tab item, instead, it only changes the DataContext and updates the "Selected Visual Item" bindings. Its loaded / unloaded events are fired, but the object is always the same.
You can use load / unload events and write your code accordingly so that your βVisual Elementβ, which is your user control, so that the control is not stateless and does not depend on old data. When the new DataContext is applied, you must update everything.
The DataContextChanged, Loaded, and Unloaded events can help you remove all dependencies on old data.
Otherwise, you will create a new TabItem manually using UserControl as your child and add it to TabControl instead of adding data items.
Adding TabItems manually will create a new control for each item, and various items based on the selection will be displayed in the selected area.
source share