Can't find what you're looking for?

Contact us or post in our forums and we'll help you find an answer.

How to expand/collapse specific categories in code for C1PropertyGrid for WPF

Background:

Arrow buttons for expansion/collapse are actually C1ExpanderButton that are part of C1Expander element present in each category. C1Expander has property IsExpanded that defines whether a category is expanded or collapsed.

So, access these C1Expander through C1PropertyGrid’s CategoryContainers and set the IsExpanded property for the specific category

Steps to Complete:

private void SetGroupState(C1PropertyGrid propGrd, string grpName, GroupState grpState)
{
     foreach(KeyValuePair kvp in propGrd.CategoryContainers.Where(x=>x.Key== grpName))
     {
          C1Expander expander = kvp.Value;
          if(expander != null)
          {
               if(grpState == GroupState.Expanded)
                   expander.IsExpanded = true;
               else
                   expander.IsExpanded = false;
          }
     }
}
public enum GroupState
{
     Expanded = 0,
     Collapsed
}
Get the Latest Version of WPF Edition
Download the Free Trial Now