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

  • SEARCH
  • Home
  • 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 5959761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:43:50+00:00 2026-05-22T18:43:50+00:00

In the following code: http://msdn.microsoft.com/en-us/library/ms754027.aspx How to Bind IsExpanded to the MyData list of

  • 0

In the following code:

http://msdn.microsoft.com/en-us/library/ms754027.aspx

How to Bind IsExpanded to the MyData list of objects, where each object has the IsExpanded property?

<Expander IsExpanded={Binding Path=IsExpanded, Mode=TwoWay} />

This doesn’t work!

MyData is List<GroupNode>;

GroupNode is a class containing notify property changed property IsExpanded.

So, if I open one of the expander manually it should set the IsExpanded property to true of that MyData’s GroupNode.

  • 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-22T18:43:51+00:00Added an answer on May 22, 2026 at 6:43 pm

    It’s not very easy to do, because the DataContext of the GroupItem is an instance of CollectionViewGroup, and this class doesn’t have a IsExpanded property. You can however specify a converter in the GroupDescription, allowing you to return a custom value for the “name” of the group (the CollectionViewGroup.Name property). This “name” can be anything; in your case, you need it to be a class that wraps the group name (e.g. grouping key) and has a IsExpanded property:

    Here’s an example:

    public class ExpandableGroupName : INotifyPropertyChanged
    {
        private object _name;
        public object Name
        {
            get { return _name; }
            set
            {
                if (_name != value)
                {
                    _name = value;
                    OnPropertyChanged("Name");
                }
            }
        }
    
        private bool? _isExpanded = false;
        public bool? IsExpanded
        {
            get { return _isExpanded; }
            set
            {
                if (_isExpanded != value)
                {
                    _isExpanded = value;
                    OnPropertyChanged("IsExpanded");
                }
            }
        }
    
        #region INotifyPropertyChanged Members
    
        public event PropertyChangedEventHandler PropertyChanged;
    
        protected virtual void OnPropertyChanged(string propertyName)
        {
            var handler = PropertyChanged;
            if (handler != null)
                handler(this, new PropertyChangedEventArgs(propertyName));
        }
    
        #endregion
    
        public override bool Equals(object obj)
        {
            return object.Equals(obj, _name);
        }
    
        public override int GetHashCode()
        {
            return _name != null ? _name.GetHashCode() : 0;
        }
    
        public override string ToString()
        {
            return _name != null ? _name.ToString() : string.Empty;
        }
    }
    

    And here’s the converter:

    public class ExpandableGroupNameConverter : IValueConverter
    {
        #region IValueConverter Members
    
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return new ExpandableGroupName { Name = value };
        }
    
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var groupName = value as ExpandableGroupName;
            if (groupName != null)
                return groupName.Name;
            return Binding.DoNothing;
        }
    
        #endregion
    }
    

    In XAML, just declare the grouping as follows:

    <my:ExpandableGroupNameConverter x:Key="groupConverter" />
    <CollectionViewSource x:Key='src' 
                          Source="{Binding Source={StaticResource MyData}, 
                                   XPath=Item}">
      <CollectionViewSource.GroupDescriptions>
        <PropertyGroupDescription PropertyName="@Catalog" Converter="{StaticResource groupConverter}" />
      </CollectionViewSource.GroupDescriptions>
    </CollectionViewSource>
    

    And bind the IsExpanded property like that:

    <Expander IsExpanded={Binding Path=Name.IsExpanded} />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following code was grabbed from MSDN: http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.stringlengthattribute.aspx [MetadataType(typeof(ProductMetadata))] public partial class Product {
I'm converting the following example code to Delphi: http://msdn.microsoft.com/en-us/library/bb176406%28v=office.12%29.aspx My code is something like:
I have been working with the following code published on msdn: http://msdn.microsoft.com/en-us/library/fx6588te.aspx I understand
I am trying to do the following: http://msdn.microsoft.com/en-us/library/dd456857.aspx I created the function in the
First off, according to http://msdn.microsoft.com/en-us/library/x0b5b5bc.aspx , the List.Find method is only listed as throwing
I'm parsing a _URB_BULK_OR_INTERRUPT_TRANSFER packet as defined in http://msdn.microsoft.com/en-us/library/windows/hardware/ff540352(v=vs.85).aspx using the following code: //parse
Following the steps detailed in http://msdn.microsoft.com/en-us/library/zt39148a.aspx#Y684 , I have created a Windows service which
It is said here: http://msdn.microsoft.com/en-us/library/aa211599%28v=office.11%29.aspx Before the procedure will run, you must connect the
I built a project as descripted in this URL: http://msdn.microsoft.com/en-us/library/ms734784.aspx I used the app.config
I was reading custom serialization article on msdn: http://msdn.microsoft.com/en-us/library/ty01x675%28VS.80%29.aspx It mentions that there are

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.