【问题标题】:WPF Extended Toolkit PropertyGrid - Expand all properties by defaultWPF 扩展工具包 PropertyGrid - 默认展开所有属性
【发布时间】:2015-11-05 10:08:08
【问题描述】:

我正在使用 Xceed WPF 扩展工具包中的 PropertyGrid。有没有一种方法可以让所有属性默认展开?实际上,我永远不需要它们“未扩展”,所以如果可以禁用“未扩展”(有没有这个词,顺便说一句?),那就更好了。

【问题讨论】:

  • 我意识到这不是一个实际的答案,但是您是否看到 Syncfusion 正在赠送他们的全套服务...syncfusion.com/products/communitylicense...这里的好处是他们有自己的论坛,其中技术人员直接回答问题。我与 Syncfusion 没有任何关系!
  • 我的意思是说 Syncfusion 包含一个属性网格!

标签: c# wpf propertygrid wpf-extended-toolkit


【解决方案1】:

如果你还在寻找一种方法来做到这一点,我只是自己想出来的。

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.
        }
    }
}

【讨论】:

    【解决方案2】:

    如果您设置 IsCategorized="False" 您将看到默认展开的所有属性:

    <xceed:PropertyGrid IsCategorized="False" SelectedObject="{Binding}"/>
    

    你也可以指定

    ShowPreview="False" ShowSearchBox="False" ShowSortOptions="False"
    ShowSummary="False" ShowTitle="False" ShowAdvancedOptions="False"
    

    禁用除主属性编辑器网格之外的所有其他部分。

    【讨论】:

      【解决方案3】:
      _propertyGrid.ExpandAllProperties();
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-03-08
        • 1970-01-01
        • 1970-01-01
        • 2015-06-23
        • 1970-01-01
        • 1970-01-01
        • 2015-05-19
        • 2023-03-18
        相关资源
        最近更新 更多