If collection changes will error be thrown?

3 posts, 1 answers
  1. Robert
    Robert avatar
    271 posts
    Member since:
    Mar 2011

    Posted 16 Sep 2011 Link to this post

    Hi there,

    Just a quick question regarding the PersistenceFramework. I haven't used the feature yet but I have a scenario and I would like to know how the Framework will react to it.

    Suppose I have TreeView filled dynamically from a database with various nodes and child nodes, say for example categories with sub products. If I save the properties of the treeview as is, and then later reload the treeview but its nodes have changed / been updated with newer products etc, will the persistence framework throw an error when reloaded with older persistence settings?

    Thanks for your time and I hope I've explained myself adequately.
  2. Answer
    Alex Fidanov
    Admin
    Alex Fidanov avatar
    636 posts

    Posted 17 Sep 2011 Link to this post

    Hi Robert,

    If I understood your scenario correctly, you have a bound the treeview control. If that is so, the persistence framework would not save the ItemsSource property. This is the default behavior, as we do not want to recreate your business objects, as their state might not be the same as when restored. For example - private setters, nested classes with no parameterless constructors, readonly collections cannot be recreated. What settings are you trying to save?

    The persistence framework works with any UIElements and their properties. It is likely to have an unexpected result when the saved objects have different structure than the ones when restoring. However, it is possible to provide a custom serialization, which can keep track of the saved and loaded objects. A similar approach is used when using the persistence framework with the RadGridView control and its Columns. The columns are not directly serialized, but only their metadata, When loading, they are matched against the autogenerated columns of the GridView and the settings are restored. You can see this example in our online samples here.

    Please let me know if you have questions on this matter.

    All the best,
    Alex Fidanov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. UI for WPF is Visual Studio 2017 Ready
  4. Robert
    Robert avatar
    271 posts
    Member since:
    Mar 2011

    Posted 17 Sep 2011 Link to this post

    Thanks very much. I haven't made anything that uses the persistence framework yet, I was just curious what would happen if I used it with a bound treeview or something similar just incase in do :-). Thank you again for your response. Rob
Back to Top