wpf - DataGrid - collapse all groups except the first one -


i have datagrid grouped itemssource. there expander on each group, can expand/collapse groups. now, i'm trying collapse groups default, leave first group expanded. items source dynamic, can't build converter check group name. must group index.

is possible in in xaml? or in code-behind?

please, help.

this might little late, in order similar problems, defining "visual tree helper class" helpful in case.

    // visual tree helper class public static class visualtreehelper {     public static collection<t> getvisualchildren<t>(dependencyobject current) t : dependencyobject     {         if (current == null)             return null;          var children = new collection<t>();         getvisualchildren(current, children);         return children;     }     private static void getvisualchildren<t>(dependencyobject current, collection<t> children) t : dependencyobject     {         if (current != null)         {             if (current.gettype() == typeof(t))                 children.add((t)current);              (int = 0; < system.windows.media.visualtreehelper.getchildrencount(current); i++)             {                 getvisualchildren(system.windows.media.visualtreehelper.getchild(current, i), children);             }         }     } }  // can use above class this: collection<expander> collection = visualtreehelper.getvisualchildren<expander>(datagrid1);      foreach (expander expander in collection)         expander.isexpanded = false;  collection[0].isexpanded = true; 

the credit goes this forum


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -