C# 如何以编程方式在Xceed PropertyGrid中对类别进行排序?

C# 如何以编程方式在Xceed PropertyGrid中对类别进行排序?,c#,wpf,wpftoolkit,propertygrid,xceed,C#,Wpf,Wpftoolkit,Propertygrid,Xceed,如中所示,我试图实现的是对XceedPropertyGrid控件中的类别进行排序 如该示例所示(复制到此处以供参考),您可以在编译时通过向类添加属性来指定此信息,如下所示 [CategoryOrder("General", 1)] [CategoryOrder("Advanced", 2)] [CategoryOrder("Other", 3)] public class MyClass { [Category("General")] public string Property

如中所示,我试图实现的是对Xceed
PropertyGrid
控件中的类别进行排序

如该示例所示(复制到此处以供参考),您可以在编译时通过向类添加属性来指定此信息,如下所示

[CategoryOrder("General", 1)]
[CategoryOrder("Advanced", 2)]
[CategoryOrder("Other", 3)]
public class MyClass {
    [Category("General")]
    public string Property1 { get; set; }
    [Category("Advanced")]
    public int Property2 { get; set; }
    [Category("Other")]
    public double Property3 { get; set; }
    [Category("General")]
    public string Property4 { get; set; }
    [Category("Advanced")]
    public int Property5 { get; set; }
    [Category("Other")]
    public double Property6 { get; set; }
}
它会出现在属性网格中,如下所示

但是,我尝试在运行时设置
CategoryOrderAttribute
值。这是我正在尝试的,但它不起作用

// Note: This gets executed *prior* to assignment to the PropertyGrid
TypeDescriptor.AddAttributes(typeof(MyClass),
    new CategoryOrderAttribute("General", 1),
    new CategoryOrderAttribute("Advanced", 2),
    new CategoryOrderAttribute("Other", 3)
);

就像我说的,这不起作用,类别仍然按字母顺序出现。知道为什么这样不行吗?

原来源代码中有两个bug。第一,它们没有覆盖CategoryOrderAttribute中的TypeID,第二,它们没有使用TypeDescriptor.GetAttributes。我已经提交了两个错误


v3.5的源代码可用