How to get group level from Expander

Aug 18, 2009 at 11:09 AM

I would like to have column headers in group headers. this is easy with one group level.
How to get group level from Expander:

private void Expander_Loaded(object sender, RoutedEventArgs e)
        {
            Expander expander = sender as Expander;
            TextBlock textBlock = expander.FindName("GroupHeaderText") as TextBlock;
            //????? how to get group level?
            textBlock.Text = "GroupHeader1/2";
        }
Thanks for help in advance!
Aug 18, 2009 at 12:37 PM

I solved the problem with two groups by :

From Converter I got:

CollectionViewGroup obj = (CollectionViewGroup)value;

if (obj.IsBottomLevel == false)
    return "First Level Header: ";
else
    return "Second Level Header: ";

What about three or more levels?

Thanks for help in advance!