单击CancelBtn取消更改 [英] On clicking CancelBtn cancel changes

查看:260
本文介绍了单击CancelBtn取消更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的程序自定义属性网格中,所有属性都可以从viewModel绑定。在这个属性网格中还有2个按钮--SaveBtn和EditBtn。 用户编辑属性网格中的属性。单击SaveBtn时,所有属性都必须保存在数据库中。如果用户想要编辑属性,则单击EditBtn,然后在将属性保存到数据库(单击SaveBtn)之前,应该出现新窗口,其中用户选择修改属性的原因。在该窗口上还有三个按钮 - ExitWithSavingToDatabase,ExitWithoutSavingToDatabase和Cancel。



如果用户选择取消,则应取消所有更改。但是viewModel中的属性已经有了新值。 我的问题是 - 如何将属性重置为旧值? 我正在考虑从数据库重新加载属性,但是如果有更好的解决方案,我可以在不使用数据库的情况下完成它?

解决方案

创建备份保持原始加载值的字段,

然后单击取消时,只需从那里重新加载。

如果单击保存选项,请使用新值更新备份字段。

I have in my program custom property grid, where all properties are bindable from viewModel. In this property grid there are also 2 buttons - SaveBtn and EditBtn. User edit properties in property grid. When SaveBtn is clicked, all properties must be saved in a database. If user wants to edit properties, he clicks EditBtn and then before saving properties to database(SaveBtn is clicked), should appear new window, where user chooses a reason of modification of a properties. On that window there are also three buttons - ExitWithSavingToDatabase, ExitWithoutSavingToDatabase and Cancel.

If user chooses Cancel, all changes should be canceled. But properties in viewModel already have new values. My question is - how can I reset properties to old values??? I was thinking of reloading properties from database, but if there is a better solution, where I can do it without using database?

解决方案

Create a backup field that maintains the original loaded values,
Then when cancel is clicked, just reload from there.
If either Save option is click, update the backupfields with the new values.


这篇关于单击CancelBtn取消更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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