Hi, does the RadDocking control use virtualization? And can I disable it? To be more specific, after a user action, I add a new Pane to a PaneGroup and set its Content and DataContext to a new ViewModel. In my App.xaml, I have a DataTemplate so that this ViewModel is shown as a certain UserControl. This works great, except that the UserControl is being reused. I can see that because I'm only entering the constructor once. Subsequent adds of ViewModels won't add new UserControls.
My real situation is a little more complex (an MVVM pattern, and a command I need to execute when each UserControl is loaded), but you can reproduce it with this setup:
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Button Click="ButtonBase_OnClick" Grid.Row="0">Click</Button>
<telerikDocking:RadDocking Grid.Row="1">
<telerikDocking:RadDocking.DocumentHost>
<telerikDocking:RadSplitContainer>
<telerikDocking:RadPaneGroup x:Name="TheRadPaneGroup">
<telerikDocking:RadPaneGroup.ItemTemplate>
<DataTemplate>
<telerik:RadPane>
<Style TargetType="telerik:RadPane">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<!--<userControlEvents:UserControl1></userControlEvents:UserControl1>-->
<ContentControl Content="{Binding}"></ContentControl>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</telerik:RadPane>
</DataTemplate>
</telerikDocking:RadPaneGroup.ItemTemplate>
</telerikDocking:RadPaneGroup>
</telerikDocking:RadSplitContainer>
</telerikDocking:RadDocking.DocumentHost>
</telerikDocking:RadDocking>
</Grid>
Putting the UserControl explicitly in the DataTemplate (and no longer relying on the App.xaml) makes no difference. Putting x:Shared="False" on the Style and/or the DataTemplate makes no difference either.
From what I've read on the interent, this has to do with Virtualization. Is there a way to disable this?
I've made a simple project and put it here. You can see a new ViewModel is added every time (because the milliseconds change for every RadPane that is added), but the second piece of text (the current date, with seconds) does not change, so the UserControl is being reused. I want it to create a new UserControl every time.
My real situation is a little more complex (an MVVM pattern, and a command I need to execute when each UserControl is loaded), but you can reproduce it with this setup:
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Button Click="ButtonBase_OnClick" Grid.Row="0">Click</Button>
<telerikDocking:RadDocking Grid.Row="1">
<telerikDocking:RadDocking.DocumentHost>
<telerikDocking:RadSplitContainer>
<telerikDocking:RadPaneGroup x:Name="TheRadPaneGroup">
<telerikDocking:RadPaneGroup.ItemTemplate>
<DataTemplate>
<telerik:RadPane>
<Style TargetType="telerik:RadPane">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<!--<userControlEvents:UserControl1></userControlEvents:UserControl1>-->
<ContentControl Content="{Binding}"></ContentControl>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</telerik:RadPane>
</DataTemplate>
</telerikDocking:RadPaneGroup.ItemTemplate>
</telerikDocking:RadPaneGroup>
</telerikDocking:RadSplitContainer>
</telerikDocking:RadDocking.DocumentHost>
</telerikDocking:RadDocking>
</Grid>
Putting the UserControl explicitly in the DataTemplate (and no longer relying on the App.xaml) makes no difference. Putting x:Shared="False" on the Style and/or the DataTemplate makes no difference either.
From what I've read on the interent, this has to do with Virtualization. Is there a way to disable this?
I've made a simple project and put it here. You can see a new ViewModel is added every time (because the milliseconds change for every RadPane that is added), but the second piece of text (the current date, with seconds) does not change, so the UserControl is being reused. I want it to create a new UserControl every time.