View declared in DataTemplate keeps on creating when changing from Tab to Tab

I have been following MVVM pattern to design my application. However, i have noticed a strange thing. I have a Tab control in which i have specified the ItemsSource as Binding for WorkSpaces from MainViewModel. In the Items, i have been adding different ViewModels. I have defined the DataTemplate for the ViewModel datatypes.

However, when i click on a tab, a new View is created everytime.

Sample code i am posting here.


<DataTemplate DataType="{x:Type spavm:DashboardViewModel}">


<dx:DXTabControl Grid.Row="2" Margin="5" 
                         ItemsSource="{Binding WorkSpaces}"
                         ItemHeaderTemplate="{StaticResource WorkspaceItemTemplate}">

From the above, if i switch to any other tab and revisit my DashboardView, it is getting created again.

Am i missing anything?? I just need a single instance of the DashboardView. How can i achieve that.


As mentioned, this is by design in DevExpress. However, there is a property called DestroyContentOnTabSwitching that you can set to false. DX Documentation.

If your views are expensive to create you could also consider refactoring the expensive logic to cache it.

Need Your Help

External Linkge drawbacks


Are there any drawbacks to having a symbol with external linkage (other then global namespace clutter/collision)? For instance, I would think that if I have a function witch I never call, if it has

Programmatically resizing/aligning loading view

ios objective-c cocoa-touch loading uiactivityindicatorview

Ok, I'm adding a loading screen to UITableViewController just like in the YouTube, AppStore or iTunes apps. And I'm doing it like this: