[英]WPF Extended Toolkit PropertyGrid - Expand all properties by default
我正在使用 Xceed WPF 扩展工具包中的 PropertyGrid。 有没有办法让所有属性默认展开? 实际上,我永远不需要它们“未扩展”,所以如果可以禁用“未扩展”(顺便说一句,有没有这样的词?),那就更好了。
如果你还在寻找一种方法来做到这一点,我只是自己想出来的。
private void PropertyGrid_SelectedObjectChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
{
var grid = sender as PropertyGrid;
foreach (PropertyItem prop in grid.Properties)
{
if (prop.IsExpandable) //Only expand things marked as Expandable, otherwise it will expand everything possible, such as strings, which you probably don't want.
{
prop.IsExpanded = true; //This will expand the property.
prop.IsExpandable = false; //This will remove the ability to toggle the expanded state.
}
}
}
如果您设置 IsCategorized="False",您将看到所有属性默认展开:
<xceed:PropertyGrid IsCategorized="False" SelectedObject="{Binding}"/>
你也可以指定
ShowPreview="False" ShowSearchBox="False" ShowSortOptions="False"
ShowSummary="False" ShowTitle="False" ShowAdvancedOptions="False"
禁用除主属性编辑器网格之外的所有其他部分。
_propertyGrid.ExpandAllProperties();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.