c# - 如何填充使用 PropertyGrid 的 CollectionEditor(扩展 WPF 工具包)时出现的 CollectionControlDialog?

标签 c# wpf wpftoolkit propertygrid collectioneditor

使用 Extended WPF Toolkit 中的 PropertyGrid,我需要使用 CollectionEditor:

[Editor(typeof(CollectionEditor), typeof(CollectionEditor))]
public Definition DefTypes { get; set; }

但是CollectionControlDialog单击 DefTypes 字段时出现的没有可供选择的项目。

那么我该如何填充这个 CollectionControlDialog

最佳答案

您的 CollectionEditor 只会显示特定类型对象的集合。在这种情况下,它看起来不像是将 Editor 属性添加到集合中,而是添加到单个对象中。

请参阅下面的代码:

public class Definition {
    public string SomeProperty { get; set; }
}

public class Definitions : List<Definition> {
}

现在您可以将 CollectionEditor 应用于定义:

[Editor(typeof(CollectionEditor), typeof(CollectionEditor))]
public Definitions DefTypes { get; set; }

它会调出具有“定义”中定义的属性的 CollectionEditor

关于c# - 如何填充使用 PropertyGrid 的 CollectionEditor(扩展 WPF 工具包)时出现的 CollectionControlDialog?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22146178/

相关文章:

javascript - 单击按钮时 Jquery 返回父函数

c# - 从源代码访问 Unity3D 的自定义全局定义

c# - 多线程 WPF Application : Dispatcher Invoke. 更高效的方法?

c# - 为什么我不能序列化其中包含结构的对象?

c# - WPFToolkit CheckComboBox 宽度问题

wpf - 如何使用复选框列和绑定(bind)从 Xceed\Extended WPF 工具包设置数据网格控件

wpftoolkit - "Input string was not in a correct format."WPF 数据网格异常

c# - 在 mac 中没有找到匹配命令 "dotnet-aspnet-codegenerator"asp.net core 2.1 项目的可执行文件

c# - 在源代码中存储加密 key 有多安全?

wpf - 选择行时设置WPF DataGrid行的文本颜色