satorp
Topic Author
Posts: 20
Joined: 12 Mar 2018, 05:48

Control states persistency

21 Feb 2023, 12:51

We're currently looking into a solution to automatically persist (serialize) control states (dependency properties) for dialogs. For example we want some controls on a dialog to resume their states (size, expanded state, ListView's column width etc) when reopening the dialog. The generic requirements are:
  • The solution should provide a way to markup persistable control properties
  • It should be extensible to all dialogs (no specific serialization codes for each dialog)
  • The serialization should be done automatically (e.g. automatic serialize/deserialize on dialog closing/loading)
For WPF, this article on CodeProject offers a very good solution by using markup extensions and automatic generation of persistence Id. The shortcomings are:
  • It uses UIElement.PersisId property which is marked obsolete in WPF
  • It utilizes logical tree path to generate a unique Id, but some control elements may not appear in logical tree (e.g. GridViewColumn)
Since Noesis implementation is not necessarily identical to WPF, I wonder if there's a better way to achieve this in Noesis.
 
User avatar
sfernandez
Site Admin
Posts: 2984
Joined: 22 Dec 2011, 19:20

Re: Control states persistency

23 Feb 2023, 11:54

The solution exposed in that article (using a MarkupExtension) looks quite good to me and can be easily implemented in Noesis.

The lack of the PersistId doesn't seem blocking as WPF implemented it just as an auto-increment counter that you can handle in the markup extension itself.

I recommend implementing that approach. If you find any trouble please let us know and we will help.
 
satorp
Topic Author
Posts: 20
Joined: 12 Mar 2018, 05:48

Re: Control states persistency

24 Feb 2023, 16:13

@sfernandez Thank you fro the reply.

I have no idea why Microsoft marked PersistId as obsolete. If it's safe and easy to implement then I think it will be nice to have it as part of Noesis framework.

Do you have a suggestion on how to deal with GridViewColumn?
 
User avatar
sfernandez
Site Admin
Posts: 2984
Joined: 22 Dec 2011, 19:20

Re: Control states persistency

01 Mar 2023, 11:38

Could you please add the PersistId request to our bugtracker?

For the GridViewColumn you can use Noesis::FindTreeElement() to find the FrameworkElement ancestor holding the column definition.
 
satorp
Topic Author
Posts: 20
Joined: 12 Mar 2018, 05:48

Re: Control states persistency

02 Mar 2023, 14:51

I've added this issue to your bugtracker.
We will try your suggestion on GridViewColumn. Thank you.

Who is online

Users browsing this forum: Google [Bot] and 34 guests