question

Upvotes
Accepted
39.3k 76 11 27

Can app data for WPF apps be saved per instance of the app?

When a user has multiple instances of my WPF app saved in a workspace, I'd like the app to save app data such as say a currency pair in focus or a radio button selected to be saved per instance of the app, so that when the workspace is opened each app is restored to the state the user saved it in. Could IAppHost.PreferencesStore or IAppHost.Storage services provide the solution here? Does either of these services save the app data per instance of the app? Or do both of these services not distinguish which instance of the app saves the data?

eikoneikon-app-studioapp
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Upvote
Accepted
52.5k 134 44 63

I used State Persistence as mentioned in this tutorial.

Persisted state

A built-in serialization mechanism can be used to persist the app’s data between different instances. The data, that is saved, will be injected as an instance of an XmlReader to the respective constructor.

...

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.