Data Error with IsContentPreserved

3 posts, 0 answers
  1. Michael
    Michael avatar
    2 posts
    Member since:
    Mar 2013

    Posted 25 Apr Link to this post


    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:

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

    What is the reason for this error?



  2. Dinko
    Dinko avatar
    182 posts

    Posted 28 Apr Link to this post

    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. 

    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. DevCraft banner
  4. Michael
    Michael avatar
    2 posts
    Member since:
    Mar 2013

    Posted 28 Apr in reply to Dinko Link to this post


    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.



Back to Top