question

Upvotes
Accepted
39.2k 75 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 5.0 MiB each and 10.0 MiB total.

1 Answer

Upvote
Accepted
38.1k 71 35 53

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 5.0 MiB each and 10.0 MiB total.

Click below to post an Idea Post Idea