简体   繁体   English

xceed Propertygrid-如何使用属性集合

[英]xceed Propertygrid - how to use a property collection

I try to use the great propertygrid from exceed.wpftoolkit but I have to problems based on the application I have to create. 我尝试使用来自extra.wpftoolkit的出色的propertygrid,但是我不得不根据必须创建的应用程序来解决问题。

First I didn't know at compile time the number of properties the grid has to show. 首先,我在编译时不知道网格必须显示的属性数量。 So I couldn't use a simple class with properties/attributes and annotations as datacontext or source for the grid, I need a list or dictionary in which I place a number of grid properties at runtime. 因此,我不能使用带有属性/属性和注释的简单类作为网格的数据上下文或源,我需要一个列表或字典,在其中运行时放置许多网格属性。 I google for several hours and try to find an example in the sample folders of the toolkit sources but nothing has help me. 我在Google上搜索了几个小时,尝试在工具包源的示例文件夹中找到一个示例,但没有任何帮助。 Second problem or apply is to replace the usage of annotations in the property class. 第二个问题或适用方法是替换属性类中注释的用法。 I need to create the properties at runtime and place the propertyeditor and annotation settings at runtime to the property. 我需要在运行时创建属性,然后在运行时将属性编辑器和注释设置放置到该属性。

Could anybody help me with some simple examples or good places to look for. 任何人都可以通过一些简单的例子或寻找好的地方来帮助我。 I believe the propertygrid is very powerful and could do this. 我相信propertygrid非常强大,可以做到这一点。

You need to create a class that implements the ICustomTypeDescriptor interface to provide all the PropertyDescriptor instances that represent your dynamic properties. 您需要创建一个实现ICustomTypeDescriptor接口的类,以提供代表动态属性的所有PropertyDescriptor实例。

After that you can set an instance of the class that implements the ICustomTypeDescriptor interfaces as SelectedObject to the PropertyGrid. 之后,您可以设置将ICustomTypeDescriptor接口作为SelectedObject到PropertyGrid的类的实例。

You can find an example here . 您可以在此处找到示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM