I have a treeview with itemsource containing items of custom class TreeviewItem.
I have a property SelectedTreeviewItemViewModel of type TreeviewItem.
public TreeviewItem SelectedTreeviewItemViewModel //with INPC
I have a content control somewhere else on the window
<ContentControl Content="{Binding SelectedTreeviewItemViewModel}" />
with a datatemplate as follow:
<DataTemplate DataType="{x:Type TreeviewItem}">
<uc:TreeviewCustomView />
</DataTemplate>
When I click on an item of the treeview, the event SelectedItemChanged is fired and I set SelectedTreeviewItemViewModel which forces the contentcontrol to refresh its content.
The logic is fine, however I noticed that when I click on a new item in the treeview, some data is updated but I don't step into the user control's constructor (uc:TreeviewCustomView).
Is there some kind of virtualization involved? I'm guessing WPF caches the datatemplate; is there any way I can force WPF to recreate the user control from scratch (thus stepping into the constructor) everytime I click on a treeview item?