This is a migrated thread and some comments may be shown as answers.

Data Error with IsContentPreserved

2 Answers 82 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 25 Apr 2016, 03:22 PM

Hi,

in my mainwindow i have a radtabcontrol and i bind it to a collection of tabitems. Further i have datatemplates for each view (user control) and a datatemplateselector. Everything works without problems but once i set the IsContentPreserved property to true i get

System.Windows.Data Error: 25 : Both 'ContentTemplate' and 'ContentTemplateSelector' are set;  'ContentTemplateSelector' will be ignored. ContentPresenter:'ContentPresenter' (Name='')

here is my xaml:

<telerik:RadWindow.Resources>
       <DataTemplate x:Key="ContentTemplateApplicationSettings">
           <local:ApplicationSettings/>
       </DataTemplate>
       <DataTemplate x:Key="ContentTemplateConversionRules">
           <local:ConversionRules/>
       </DataTemplate>
       <DataTemplate x:Key="ContentTemplateProductionOrderConversion">
           <local:ProductionOrderConversion/>
       </DataTemplate>
       <localutil:MainMenuContentTemplateSelector x:Key="MainMenutemplateSelector"
               ApplicationSettingsTemplate="{StaticResource ContentTemplateApplicationSettings}"
               ConversionRulesTemplate="{StaticResource ContentTemplateConversionRules}"
               ProductionOrderConversionTemplate="{StaticResource ContentTemplateProductionOrderConversion}"/>
   </telerik:RadWindow.Resources>
   <Grid>
       <Grid.RowDefinitions>
           <RowDefinition/>
           <RowDefinition Height="Auto"/>
       </Grid.RowDefinitions>
       <telerik:RadTabControl x:Name="MainMenuTabControl"
                              IsContentPreserved="True"
                              ItemsSource="{Binding MainMenuTabItems}"
                              ContentTemplateSelector="{StaticResource MainMenutemplateSelector}">
           <telerik:RadTabControl.ItemTemplate>
               <DataTemplate>
                   <TextBlock Text="{Binding Header}" />
               </DataTemplate>
           </telerik:RadTabControl.ItemTemplate>
       </telerik:RadTabControl>
       <StatusBar Grid.Row="1" Background="{StaticResource HeaderAndStatusBackground}">
           <StatusBarItem>
               <TextBlock Text="{Binding StatusText}" Foreground="White"/>
           </StatusBarItem>
       </StatusBar>
   </Grid>


What is the reason for this error?

thanks, 

michael

2 Answers, 1 is accepted

Sort by
0
Dinko
Telerik team
answered on 28 Apr 2016, 11:14 AM
Hi Michael,

We are aware of this warning. Basically, we are setting the ContentTemplate and the ContentTemplateSelector in code to the dynamically created persisted content presenter (which corresponds to the IsContentPreserved logic) and that is why there is such warning. Setting the IsContentPreserved property preserves the content of all tabs no matter which of the two properties is set ContentTemplate or ContentTemplateSelector. The data will be load only the first time and will be preserved when you change tabs. This warning shouldn't cause any problem to your application.

If this warning is stopping you from proceeding further with your application you can contact us again with more information about your case. 

Regards,
Dinko
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Michael
Top achievements
Rank 1
answered on 28 Apr 2016, 11:35 AM

Hi,

no, it is not stopping me from proceeding. I was just wondering if there is a way to get rid of this warning. 

Thanks for your answer.

br,

michael

Tags
TabControl
Asked by
Michael
Top achievements
Rank 1
Answers by
Dinko
Telerik team
Michael
Top achievements
Rank 1
Share this question
or