Click here to Skip to main content
15,918,343 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using WPF in VB. My window contains radio buttons and combo boxes. I am wondering how can I save those in textfiles? Would you help me?

1 solution

Don't save or load controls. Have a data layer made of pure data classes and have a procedures for populating UI from the model and updating model form UI. Think "controller" or "data binding". The effort of adding this extra layer will pay off pretty soon.

When you do it, saving a data model anywhere won't be a problem. If you want to persist data in a file/stream, there is nothing better than Data Contract.


See also my past solutions advocating Data Contract approach:
How can I utilize XML File stream writer and reader in my form application?[^],
Creating property files...[^],
deseralize a json string array[^].


JayShim wrote:
I appreciate your help very much. May I have more help on your suggestion? How can I use "controller or data binding"?

Certainly, but the answers would go well beyond the format of CodeProject Quick Questions & Answers.

First, by "controller" I mean an the architectural component as it is understood in the Model–View–Controller (MVC) architectural pattern. Read about it:[^],[^].

From the first of the above two links, you will be able to find further references to some MVC frameworks available for .NET, but you can also just use the architectural approach itself. Also, as you use WPF, pay attention to another architectural pattern called Model View ViewModel (MVVM) which is largely based on MVC and mostly targeted to be used with WPF or Silverlight. Please see:[^],[^],[^],
some frameworks:[^].

In the first of the articles referenced below, you will find other Open-Source frameworks based on MVVM.

Now, about data binding. This is a widely uses conception used in WFP, Silverlight, System.Windows.Forms, ASP.NET and other libraries. As you work with WPF, start here:[^].

Good luck,
Share this answer
JayShim 29-Nov-11 11:45am    
I appreciate your help very much. May I have more help on your suggestion? How can I use "controller or data binding"?
Sergey Alexandrovich Kryukov 30-Nov-11 20:40pm    
Sure. That goes deep and would require a big article on each topic, if not a book. So, I can only give you some reference to start with. Using further references in the articles I referenced you can find everything from introductions to code samples and sample projects. Please see my updated solution above, after [EDIT].

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900