![](/img/trans.png)
[英]How can you hide a sub-property in the Xceed PropertyGrid for WPF?
[英]How can you programmatically order categories in the Xceed PropertyGrid?
如此处的示例所示,我试图实现的是对 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; }
}
它会像这样出现在PropertyGrid
......
然而,我想要做的是在运行时设置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)
);
就像我说的,这不起作用,类别仍然按字母顺序显示。 知道为什么这不起作用吗?
结果发现源中有两个错误。 一,它们没有覆盖 CategoryOrderAttribute 中的 TypeID,二,它们没有使用 TypeDescriptor.GetAttributes。 我已经为两者提交了错误...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.