开发者

Save/Load User Settings on multiple UserControls within a Window

This post is related to c# - approach for saving user settings in a WPF application?

I have found multiple examples for saving/loading one window configuration but I am not sure if it will also save the configurations for all usercontrols open inside that window or just the actual main windows configuration...

First is it possible to save/load multiple usercontrol configurations inside a window using the application/user settings?

Am I forced to just read/write xml to store the the multiple usercontrols configuration?

Thanks in advance and let me know if you need any other information!

EDIT

I have an application with a ribbonbar on top that allows the user to open one or more user controls from t开发者_高级运维he ribbonbar. Hypothetically if i wanted to save all the open usercontrols window position, height, width, etc... would it still be possible to use the application settings to accomplish this?

EDIT2

I have an application and within that application there are many usercontrols a user can access. If a user opens 2 usercontrols and uses those controls often, I want to be able to save those usercontrols to the workspace so there always there when the program is open or closed. The way I am approaching it now is with serialized xml from the database. I was researching this topic and came across the application settings approach and wanted to know if this was a viable approach for my situation. Thanks again Marc for taking the time to help me figure this problem out.


What I've used is user-specific ApplicationSettings and binding those to properties I want to 'save'. Here's a good example of what I've done http://www.jaylee.org/post/2007/02/WPF-DataBinding-and-Application-Settings.aspx


I little more detail might be helpful here, I'm not sure I follow. Are you saying you have multiple instances of a given user control on a single window and you want to persist the properties for each of them?

A lot of this depends on how you created and populated those controls. If they were created dynamically from data for example, the best solution is to serialize that data to disk and re-create the controls when the application restarts.

Alternatively you could bake in the serialization of the settings into the user control itself such that it writes out it's settings to a file name based on it's instance name (control1.xml, control2.xml, etc) and then have it repopulate when the instance comes back to life.

Knowing how these controls are added and the properties are set in first place would be helpful.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜