We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

PropertyGrid expand all properties and property order

Hi.
Is there any way to expand all nodes in PropertyGrid by code (expandMode is set to NestedNode)?
It's possile to set custom order of properties? For example xceed property grid has a PropertyOrder attribute which i can defne it per class property. Is there any similar way of doing this, displaying property c, a, b instead of a, b, c.?

Thanks

5 Replies

KJ Keerthana Jegannathan Syncfusion Team February 7, 2017 01:19 PM UTC

Hi Bojan, 
 
Thanks for contacting Syncfusion support. 
 
Query 1: Is there any way to expand all nodes in PropertyGrid by code (expandMode is set to NestedNode)? 
 
In PropertyGrid, at present there is no default support to expand all the nodes be code behind. We have prepared a workaround sample in which we have iterate through the PropertyViewItem and expand it based on the ToggleButton visibility and it can be downloaded from the below location. 
 
 
Query 2: It's possile to set custom order of properties? For example xceed property grid has a PropertyOrder attribute which i can defne it per class property. Is there any similar way of doing this, displaying property c, a, b instead of a, b, c.? 
 
We have considered your requirement as feature and it will be available in any of our upcoming releases. Please check our website periodically to know the features that are implemented.

Regards,
Keerthana J 



IB ibK September 19, 2018 08:39 AM UTC

Try to do this in a own PropertyGrid class, but dont work:

using System;
using System.Windows;
using System.Windows.Controls.Primitives;
using Syncfusion.Windows.PropertyGrid;
using Syncfusion.Windows.Shared;

namespace ibKastl.MD3.Gui.UserControls.PropertyGrid
{
  class MD3PropertyGrid : Syncfusion.Windows.PropertyGrid.PropertyGrid
  {
    public MD3PropertyGrid() : base()
    {
      Loaded += OnLoaded;
    }

    private void OnLoaded(object sender, RoutedEventArgs e)
    {
      if (VisualUtils.FindDescendant(this, typeof(PropertyView)) is PropertyView item)
      {
        item.ItemContainerGenerator.StatusChanged += ItemContainerGenerator_StatusChanged;
      }
    }

    private void ItemContainerGenerator_StatusChanged(object sender, EventArgs e)
    {
      foreach (PropertyCatagoryViewItem item in VisualUtils.EnumChildrenOfType(this, typeof(PropertyCatagoryViewItem)))
      {
        item.IsExpanded = true;
        foreach (var items in item.Items)
        {
          foreach (PropertyViewItem propertyviewitem in VisualUtils.EnumChildrenOfType(this, typeof(PropertyViewItem)))
          {
            ToggleButton button = (ToggleButton)propertyviewitem.Template.FindName("PART_Toggle", propertyviewitem);
            if (button.Visibility == System.Windows.Visibility.Visible)
            {
              button.IsChecked = true;
            }
          }

        }
      }
    }
  }
}



SK Senthil Kumaran Rajan Syncfusion Team September 20, 2018 05:49 AM UTC

Hi IbKastal 
 
Thank you for the update 
 
We have checked the reported query that the code for expand all nodes is not working in propertygrid. We have checked the same, by creating the custom class of PropertyGrid, but the code for expanding all nodes of properties in PropertyGrid is working fine at our end. Please find the sample for the same from following location: 
 
 
Screenshot: 
 
 
 
Please check with this sample and screenshot and let us know whether you are meant about this? If not, please brief about the case in which you are facing the issue, it would be helpful for us to proceed on this.  
 
Regards, 
Senthil 



SU sungjin July 7, 2020 01:46 AM UTC

Hi.

It doesn't worked. I'm using WPF version 18.1460.0.52

In the sample " Samplehttp://www.syncfusion.com/downloads/support/forum/128688/ze/PropertyGridCustomObjectSample_modified223251944 "

(ToggleButton)propertyviewitem.Template.FindName("PART_Toggle", propertyviewitem);

always returns a null.
As a result, the example throws "System.NullReferenceException"

Regards,
Sungjin


UN Unknown Syncfusion Team July 7, 2020 07:11 AM UTC

Hi Sungjin, 

Thanks for contacting Syncfusion support. 

We have checked your query “ToggleButton in PropertyViewItem always return null in PropertyGrid” and this is due that PART_Toggle has been replaced with ToggleButton in our latest versions. Please refer the below code snippet and sample for same . 

C#:                                 
foreach (PropertyViewItem propertyviewitem in VisualUtils.EnumChildrenOfType(this, typeof(PropertyViewItem))) 
                    { 
                        ToggleButton button = (ToggleButton)propertyviewitem.Template.FindName("ToggleButton", propertyviewitem); 
                        if ( button != null && button.Visibility == System.Windows.Visibility.Visible) 
                        { 
                            button.IsChecked = true; 
                        } 
                    } 


Regards, 
Niranjan Kumar Gopalan 


Loader.
Up arrow icon