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

    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. Dinko
    Admin
    Dinko avatar
    201 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. 

    Regards,
    Dinko
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Michael
    Michael avatar
    2 posts
    Member since:
    Mar 2013

    Posted 28 Apr in reply to Dinko Link to this post

    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

Back to Top