[英]How to stored data in WPF MVVM app without database?
I have started writing one application using WPF and encountered the problem of is it possible to stored data in MVVM without database or XML files? 我已经开始使用WPF编写一个应用程序,遇到的问题是可以在没有数据库或XML文件的情况下将数据存储在MVVM中吗?
The data don't need to be saved after close program so should I store they in ViewModel or there is any better way to do it? 关闭程序后不需要保存数据,因此我应该将其存储在ViewModel中还是有更好的方法呢?
If I were you, I would create a Model class for the information that needs to be stored. 如果您是我,我将为需要存储的信息创建一个Model类。 The ViewModel would reference this, and the View would display.
ViewModel将引用此内容,然后将显示View。
Like 喜欢
public class Settings : INotifyPropertyChanged
{
public Color AccentColor {get;set;} //Implement your callback functions ...
public string Name {get; set;}
}
And, when the time comes that you choose to implement an xml saver, you can easily do it via applying the SerializableAttribute attribute. 而且,当您选择实现xml saver时,可以通过应用SerializableAttribute属性轻松地做到这一点。
Hope this helped, and hope that I understood your problem correctly. 希望这对您有所帮助,并希望我能正确理解您的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.