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/

相关文章:

wpf - 如何在 WPF XAML 中的多重绑定(bind)中使用 stringformat

c# - 如何在 WPF 上加载 GIF?

wpf - 嵌套的 WPF 数据网格

wpf - 免费 WPF 轮播实现

c# - 发送 html 电子邮件和纯文本作为替代

c# - 如何将类型为 '<TakeIterator>[System.Data.DataView]' 的对象转换为类型 'System.Data.DataView'。?

c# - 给出十六进制颜色代码作为 gridview 背景颜色

c# - WPF 中针对不同客户的不同 GUI 定义

wpf - 我应该使用哪些 WPF 框架?

c# - 扩展的WPF工具包-WatermarkPasswordBox防止输入回车值