Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6192793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:00:25+00:00 2026-05-24T03:00:25+00:00

I’m trying to do as much as possible in the Xaml (rather than code-behind)

  • 0

I’m trying to do as much as possible in the Xaml (rather than code-behind) for a relatively simple application. I have the DataGrid bound to a DomainDataSource in Silverlight 4 and I’m binding the DomainDataSource’s GroupDescriptors to ComboBoxes allowing the user to group the rows in the DataGrid according to values they select. I’d like to give them the ability to click a button to collapse/expand all groups. I know this can be done using a PagedCollectionView, but then I end up doing the grouping, etc. in code-behind. Is there a way to accomplish this without using a PagedCollectionView?

I’m aware of the DataGrid.CollapseRowGroup(CollectionViewGroup collectionViewGroup, bool collapseAllSubgroups) method, but I haven’t found a way to iterate through the top-level groups.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T03:00:26+00:00Added an answer on May 24, 2026 at 3:00 am

    Here’s what I came up with. It provides flexibility to expand or collapse all levels or specific levels. (This could be refactored to remove duplicate code, if desired.) To expand or collapse all groups at all levels in a single call, simply pass in “0” for the groupingLevel parameter and “true” for the collapseAllSublevels parameter. By using a HashSet, duplicates are automatically eliminated from the “groups” collection.

        /// <summary>
        /// Collapse all groups at a specific grouping level.
        /// </summary>
        /// <param name="groupingLevel">The grouping level to collapse. Level 0 is the top level. Level 1 is the next level, etc.</param>
        /// <param name="collapseAllSublevels">Indicates whether levels below the specified level should also be collapsed. The default is "false".</param>
        private void CollapseGroups(int groupingLevel, bool collapseAllSublevels = false)
        {
            if (myGrid.ItemsSource == null)
                return;
            HashSet<CollectionViewGroup> groups = new HashSet<CollectionViewGroup>();
            foreach (object item in myGrid.ItemsSource)
                groups.Add(myGrid.GetGroupFromItem(item, groupingLevel));
            foreach (CollectionViewGroup group in groups)
                myGrid.CollapseRowGroup(group, collapseAllSublevels);
        }
    
        /// <summary>
        /// Expand all groups at a specific grouping level.
        /// </summary>
        /// <param name="groupingLevel">The grouping level to expand. Level 0 is the top level. Level 1 is the next level, etc.</param>
        /// <param name="expandAllSublevels">Indicates whether levels below the specified level should also be expanded. The default is "false".</param>
        private void ExpandGroups(int groupingLevel, bool expandAllSublevels = false)
        {
            if (myGrid.ItemsSource == null)
                return;
            HashSet<CollectionViewGroup> groups = new HashSet<CollectionViewGroup>();
            foreach (object item in myGrid.ItemsSource)
                groups.Add(myGrid.GetGroupFromItem(item, groupingLevel));
            foreach (CollectionViewGroup group in groups)
                myGrid.ExpandRowGroup(group, expandAllSublevels);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
this is what i have right now Drawing an RSS feed into the php,
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Does anyone know how can I replace this 2 symbol below from the string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.