c# - 自定义属性描述符和扁平化层次结构

标签 c# binding propertydescriptor

我有一个自定义属性描述符,用于支持展平对象层次结构。

为了实现这一点,我对 PropertyDescriptor 进行了子类化,并将一个链表存储到我要检索其值的“下一个”(子)属性。

这使我能够以“平面”方式将子属性绑定(bind)到网格(导出到 excel 等)。

例如。 网格(绑定(bind)属性,标题)

Col1:Customer.Name(Customer)
Col2:Customer.Address(Address)
Col3:Customer.OutstandingOrders.Count(Outstanding Orders)

问题是,一旦我添加了一个具有重复名称的列,无论它是否具有唯一的标题,它都会检索第一个的属性,但仍将正确的标题放入:

Col4:Customer.Company.Name(Company)

有什么想法吗?

最佳答案

The problem is that once I add in a column with a duplicate name, regardless of the fact it's got a unique caption it will retrieve the property for the 1st one but still put the correct header in.

你能澄清一下那条线吗?我以前做过,但我使用了假想名称中的导航路径 - 即我可能有 PropertyDescriptor.Name 报告 Customer_Company_Name 而不是 Name,并使用 .DisplayName 来报告更具可读性的内容。

关于c# - 自定义属性描述符和扁平化层次结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/784742/

相关文章:

c# - 如何强调工具提示中显示的 xml-doc 中的单词?

c# - 隐式修饰由智能感知接口(interface)公开的方法

c# - 尽管在XAML中为UI元素设置了 “”,但GetValue(NameProperty)返回 “x:Name”

ios - 为 Xamarin END UP 绑定(bind) iOS 嵌入式框架是否会出现异常?

c# - var 关键字并不总是有效?

python - 类和实例上的描述符行为差异

c# - 构建复杂的条件绑定(bind)的最佳方式

c# - 方法中类名的别名

programming-languages - 静态/动态类型与静态/动态绑定(bind)

c# - 派生类无法使用 PropertyDescriptorCollection.SetValue 访问 protected setter