Issue with DataTemplate and Persistence Framework

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

    Posted 12 May 2015 Link to this post

    Hello, I am wondering if there is a known issue with items within a DataTemplate not persisting in Persistence Framework? I have a WPF application that has many RadGridViews. I use PersistenceManager to load and save grid settings from isolated storage. Persisting column orders and column sizes work perfectly on all of my grids. However there is one grid that uses a DataTemplate to contain a button for one column. Whenever the settings for this grid are saved and then reloaded the buttons disappear. Everything else on the grid persists, but the button is gone. I tried it on a simple test project to make sure that it wasn't some sort of binding issue and the problem remains. Here is the Test grid I try to persist.

    <telerik:RadGridView x:Name="grdTest1"
                                                Margin="0,5,0,0" IsFilteringAllowed="True" Background="Blue"
                                                AlternateRowBackground="DarkGray" AlternationCount="2"
                                                IsReadOnly="True" AutoGenerateColumns="False"
                                                Visibility="Visible" MaxHeight="250">
                                    <Button Content="Test" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" />
                        <telerik:GridViewDataColumn Header="First Name" DataMemberBinding="{Binding FirstName}"/>
                    <telerik:GridViewDataColumn Header="Last Name" DataMemberBinding="{Binding LastName}"/>

    When loaded the first time the button is there. If I close and reopen (Save and Load) the button disappears. If I manually delete the persistence manager file from isolated storage and reload the button is there. The rest of the settings will persist which is great, but the button does not. Please let me know if there is a way to use persistence framework on a grid in this scenario.



  2. Martin Ivanov
    Martin Ivanov avatar
    1591 posts

    Posted 13 May 2015 Link to this post

    Hi Michael,

    The persistence framework does not persists DataTemplates and other properties that contains complex objects. You can find the persisted types in the Getting Started help article.

    To resolve this you can define the DataTemplate in the application's resources and when you load the gridview, set the template manually. Here is an example:
        <DataTemplate x:Key="cellTemp">
            <Button Content="Test" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" />

    IsolatedStorageProvider provider = new IsolatedStorageProvider();
    this.grdTest1.Columns[0].CellTemplate = this.Resources["cellTemp"] as DataTemplate;

    You can also take a look at Custom Property Provider help article and the GridView Serialization example.

    Please let me know if you need any further assistance.

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top