C# - 在WPF应用程序保存用户设置的方法呢? [英] c# - approach for saving user settings in a WPF application?

查看:1212
本文介绍了C# - 在WPF应用程序保存用户设置的方法呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你推荐一个WPF窗口(桌面)的应用程序坚持用户设置有什么办法?注意,这个想法是,用户可以在启动应用程序时以后的应用程序将使用当前设置在运行时改变其设置,然后可以关闭该应用程序,然后。有效地那么它就会出现,如果应用程序的设置不会改变。

What approach do you recommend for persisting user settings in a WPF windows (desktop) application? Note that the idea is that the user can change their settings at run time, and then can close down the application, then when starting up the application later the application will use the current settings. Effectively then it will appear as if the application settings do not change.

Q1 - 数据库或其他的方法呢?我有,我会用反正因此使用该数据库中的表是一样好,任何方式SQLite数据库?

Q1 - Database or other approach? I do have a sqlite database that I will be using anyway hence using a table in the database would be as good as any approach?

Q2 - 如果数据库:什么数据库表设计?一个表,一个可能有(例如字符串列不同的数据类型日期时间等),或只是一个带有字符串时,你必须序列化和反序列化值数值表?我想第一个会更容易,如果没有很多设置的开销并不多?

Q2 - If Database: What database table design? One table with columns for different data types that one might have (e.g. string, long, DateTime etc) OR just a table with a string for the value upon which you have to serialize and de-serialize the values? I'm thinking the first would be easier, and if there aren't many settings the overhead isn't much?

Q3 - 可用于该应用程序设置?如果是的话有没有需要在这里实现持久的任何特殊任务?同样会发生什么,在这种情况下的应用程序设置设计的默认值,再使用?会默认覆盖被保存运行的应用程序之间的任何设置? (或者将你需要不使用默认值)

Q3 - Could Application Settings be used for this? If so are there any special tasks required to enable the persistence here? Also what would happen re usage of the "default" value in the Application Settings designer in this case? Would the default override any settings that were saved between running the application? (or would you need to NOT use the default value)

推荐答案

您可以使用此项目的设置,使用的数据库是不是最好的选择考虑消耗读写的设置(特别是如果你使用Web服务)的时候

You can use project settings for this, using database is not the best option considering the time consumed to read and write the settings(specially if you use web services).

下面是几个环节,说明如何实现这一点 -

Here are few links which explains how to achieve this -

用户设置

<一个href="http://khason.net/blog/quick-wpf-tip-how-to-bind-to-wpf-application-resources-and-settings/">Quick WPF提示:如何绑定到WPF应用程序资源和设置

一个可配置的窗口为WPF

这篇关于C# - 在WPF应用程序保存用户设置的方法呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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