![](/img/trans.png)
[英]WPF Toolkit PropertyGrid ExpandableObject attribute doesn't show nested class correctly
[英]PropertyGrid - Specify ExpandableObject if I don't have control of the class
我嘗試使用PropertyGrid(實際上,它是xceed wpf工具包的propertygrid,但是如果可以簡化,我可以切換到標准形式的PropertyGrid),並且我需要在網格中顯示的對象具有一些我需要的子對象才能擴展。
我發現可以通過使用“ ExpandableObject”屬性標記屬性來實現此目的。 但是,在某些情況下,我不是該類的作者(或者我是該類的作者,但不想將其與GUI-stuff混淆),因此無法添加此類屬性。
還有其他方法可以告訴PropertyGrid哪些屬性應該可擴展?
Xceed屬性網格具有一個事件PreparePropertyItem
。 您可以處理它並設置e.PropertyItem.IsExpandable
屬性。 有一個使所有非基本屬性都可擴展的處理程序示例:
private void propertyGrid_PreparePropertyItem(object sender, Xceed.Wpf.Toolkit.PropertyGrid.PropertyItemEventArgs e)
{
var item = e.Item as Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem;
if (item == null)
return;
if (!item.PropertyType.IsValueType && item.PropertyType != typeof(string))
{
e.PropertyItem.IsExpandable = true;
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.