保存单选按钮和组合框 [英] saving radio button and combo box

查看:111
本文介绍了保存单选按钮和组合框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在VB中使用WPF.我的窗口包含单选按钮和组合框.我想知道如何将它们保存在文本文件中?

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?

推荐答案

不要保存或加载控件.具有由纯数据类组成的数据层,并具有从模型填充UI和更新模型表单UI的过程.考虑控制器"或数据绑定".添加此额外层的工作将很快获得回报.

当您这样做时,将数据模型保存在任何地方都不会成为问题.如果要将数据持久存储在文件/流中,没有什么比 Data Contract 更好的了.

请参阅 http://msdn.microsoft.com/en-us/library/ms733127.aspx [ ^ ].

另请参阅我过去提倡数据合同方法的解决方案:
如何使用XML File Stream编写器和阅读器在我的表单应用程序中? [ ^ ],
创建属性文件... [反序列化json字符串数组 [
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 http://msdn.microsoft.com/en-us/library/ms733127.aspx[^].

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写道:
JayShim wrote:

非常感谢您的帮助.我可以为您的建议提供更多帮助吗?如何使用控制器或数据绑定"?

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


当然,但是答案远远超出了CodeProject快速问答的格式.答案.

首先,通过控制器" 是指在模型-视图-控制器(MVC)建筑模式中可以理解的建筑组件.请阅读以下内容:
http://en.wikipedia.org/wiki/Model%E2%80% 93view%E2%80%93controller [ ^ ],
http://en.wikipedia.org/wiki/Architectural_pattern_(computer_science) [ http://en.wikipedia.org/wiki/MVVM [ http://code.msdn.microsoft.com/How-to-implement-MVVM-71a65441 [ ^ ],
http://wpf.codeplex.com/wikipage?title=WPF% 20Model-View-ViewModel%20Toolkit& referringTitle = Home [ ^ ],
一些框架:
http://cinch.codeplex.com/ [ ^ ].

在下面引用的第一篇文章中,您将找到基于MVVM的其他开放源代码框架.

现在,关于数据绑定.这是WFP,Silverlight,System.Windows.Forms,ASP.NET和其他库中广泛使用的概念.使用WPF时,请从这里开始:
http://msdn.microsoft.com/en-us/library/ms750612.aspx [ ^ ].

祝你好运,

—SA


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:
http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller[^],
http://en.wikipedia.org/wiki/Architectural_pattern_(computer_science)[^].

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:
http://en.wikipedia.org/wiki/MVVM[^],
http://code.msdn.microsoft.com/How-to-implement-MVVM-71a65441[^],
http://wpf.codeplex.com/wikipage?title=WPF%20Model-View-ViewModel%20Toolkit&referringTitle=Home[^],
some frameworks:
http://cinch.codeplex.com/[^].

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:
http://msdn.microsoft.com/en-us/library/ms750612.aspx[^].

Good luck,

—SA


这篇关于保存单选按钮和组合框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆