【发布时间】:2014-09-01 14:48:48
【问题描述】:
所以我有 4 个类,例如:
Class A Inherits I
Public name as String
Public ID as Integer
Class B Inherits I
Public test as String
Public somethingElse as Integer
Class C Inherits I
Public banana as String
Public Type as String
Public length as Integer
Class D Inherits I
Public name as String
Public ID as String
假设我的 WPF 应用程序中有一个 ComboBox,其中包含 I 对象的列表(一些属于 A 类类型,一些属于 C 类类型等)。
When one is selected, I want the datagrid to populate with the public variables of the selected class - variable names in the left column and values in the right.
我希望右侧的列是可编辑的,但不直接更新类中的变量。
然后,我的问题是 - 如果每个类中的所有/某些变量都不同,我如何将数据网格绑定到选定的类?然后我如何保持与变量的关联,以便在用户所做的更改通过我的自定义验证时稍后更新它?
我的想法(我不知道如何实现):
每个类是否都需要某种 DataGrid 可以绑定的转换器方法?但如果是这样,该方法会返回什么?
我是否只需要跟踪每个类的第 1 行包含此变量等,以便稍后更新?
【问题讨论】:
标签: wpf vb.net data-binding datagrid