question

Upvotes
Accepted
39.4k 77 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.

@Alex Putkov.

Hi,

This question was posted with visibility private to TR developers (see padlock above).

However, after verifying the content, it doesn't contain any sensitive information. I have changed it to public so the entire community can see it.

Thanks,
AHS

1 Answer

· Write an Answer
Upvote
Accepted
78.8k 250 52 74

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.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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