CollectionViewGroup.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / Data / CollectionViewGroup.cs / 1305600 / CollectionViewGroup.cs

                            //---------------------------------------------------------------------------- 
//
// 
//    Copyright (C) 2003 by Microsoft Corporation.  All rights reserved.
//  
//
// 
// Description: A CollectionViewGroup, as created by a CollectionView according to a GroupDescription. 
//
// See spec at http://avalon/connecteddata/Specs/Grouping.mht 
//
//---------------------------------------------------------------------------

using System.Collections.ObjectModel; 
using System.ComponentModel;
 
namespace System.Windows.Data 
{
    ///  
    /// A CollectionViewGroup, as created by a CollectionView according to a GroupDescription.
    /// 
    abstract public class CollectionViewGroup : INotifyPropertyChanged
    { 
        #region Constructors
 
        //----------------------------------------------------- 
        //
        //  Constructors 
        //
        //-----------------------------------------------------

        ///  
        /// Initializes a new instance of CollectionViewGroup.
        ///  
        protected CollectionViewGroup(object name) 
        {
            _name = name; 
            _itemsRW = new ObservableCollection();
            _itemsRO = new ReadOnlyObservableCollection(_itemsRW);
        }
 
        #endregion Constructors
 
        #region Public Properties 

        //------------------------------------------------------ 
        //
        //  Public Properties
        //
        //----------------------------------------------------- 

        ///  
        /// The name of the group, i.e. the common value of the 
        /// property used to divide data items into groups.
        ///  
        public object Name
        {
            get { return _name; }
        } 

        ///  
        /// The immediate children of the group. 
        /// These may be data items (leaves) or subgroups.
        ///  
        public ReadOnlyObservableCollection Items
        {
            get { return _itemsRO; }
        } 

        ///  
        /// The number of data items (leaves) in the subtree under this group. 
        /// 
        public int ItemCount 
        {
            get { return _itemCount; }
        }
 
        /// 
        /// Is this group at the bottom level (not further subgrouped). 
        ///  
        public abstract bool IsBottomLevel
        { 
            get;
        }

        #endregion Public Properties 

        #region INotifyPropertyChanged 
 
        /// 
        /// PropertyChanged event (per ). 
        /// 
        event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged
        {
            add     { PropertyChanged += value; } 
            remove  { PropertyChanged -= value; }
        } 
 
        /// 
        /// PropertyChanged event (per ). 
        /// 
        protected virtual event PropertyChangedEventHandler PropertyChanged;

        ///  
        /// Raises a PropertyChanged event (per ).
        ///  
        protected virtual void OnPropertyChanged(PropertyChangedEventArgs e) 
        {
            if (PropertyChanged != null) 
            {
                PropertyChanged(this, e);
            }
        } 

        #endregion INotifyPropertyChanged 
 
        #region Protected Properties
 
        //------------------------------------------------------
        //
        //  Protected Properties
        // 
        //------------------------------------------------------
 
        ///  
        /// The items of the group.
        /// Derived classes can add or remove items using this property; 
        /// the changes will be reflected in the public Items property.
        /// 
        protected ObservableCollection ProtectedItems
        { 
            get { return _itemsRW; }
        } 
 
        /// 
        /// The number of data items (leaves) in the subtree under this group. 
        /// Derived classes can change the count using this property;
        /// the changes will be reflected in the public ItemCount property.
        /// 
        protected int ProtectedItemCount 
        {
            get { return _itemCount; } 
            set 
            {
                _itemCount = value; 
                OnPropertyChanged(new PropertyChangedEventArgs("ItemCount"));
            }
        }
 
        #endregion Protected Properties
 
        #region Private Fields 

        //----------------------------------------------------- 
        //
        //  Private Fields
        //
        //------------------------------------------------------ 

        object                                  _name; 
        ObservableCollection            _itemsRW; 
        ReadOnlyObservableCollection    _itemsRO;
        int                                     _itemCount; 

        #endregion Private Fields
    }
} 


// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
//---------------------------------------------------------------------------- 
//
// 
//    Copyright (C) 2003 by Microsoft Corporation.  All rights reserved.
//  
//
// 
// Description: A CollectionViewGroup, as created by a CollectionView according to a GroupDescription. 
//
// See spec at http://avalon/connecteddata/Specs/Grouping.mht 
//
//---------------------------------------------------------------------------

using System.Collections.ObjectModel; 
using System.ComponentModel;
 
namespace System.Windows.Data 
{
    ///  
    /// A CollectionViewGroup, as created by a CollectionView according to a GroupDescription.
    /// 
    abstract public class CollectionViewGroup : INotifyPropertyChanged
    { 
        #region Constructors
 
        //----------------------------------------------------- 
        //
        //  Constructors 
        //
        //-----------------------------------------------------

        ///  
        /// Initializes a new instance of CollectionViewGroup.
        ///  
        protected CollectionViewGroup(object name) 
        {
            _name = name; 
            _itemsRW = new ObservableCollection();
            _itemsRO = new ReadOnlyObservableCollection(_itemsRW);
        }
 
        #endregion Constructors
 
        #region Public Properties 

        //------------------------------------------------------ 
        //
        //  Public Properties
        //
        //----------------------------------------------------- 

        ///  
        /// The name of the group, i.e. the common value of the 
        /// property used to divide data items into groups.
        ///  
        public object Name
        {
            get { return _name; }
        } 

        ///  
        /// The immediate children of the group. 
        /// These may be data items (leaves) or subgroups.
        ///  
        public ReadOnlyObservableCollection Items
        {
            get { return _itemsRO; }
        } 

        ///  
        /// The number of data items (leaves) in the subtree under this group. 
        /// 
        public int ItemCount 
        {
            get { return _itemCount; }
        }
 
        /// 
        /// Is this group at the bottom level (not further subgrouped). 
        ///  
        public abstract bool IsBottomLevel
        { 
            get;
        }

        #endregion Public Properties 

        #region INotifyPropertyChanged 
 
        /// 
        /// PropertyChanged event (per ). 
        /// 
        event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged
        {
            add     { PropertyChanged += value; } 
            remove  { PropertyChanged -= value; }
        } 
 
        /// 
        /// PropertyChanged event (per ). 
        /// 
        protected virtual event PropertyChangedEventHandler PropertyChanged;

        ///  
        /// Raises a PropertyChanged event (per ).
        ///  
        protected virtual void OnPropertyChanged(PropertyChangedEventArgs e) 
        {
            if (PropertyChanged != null) 
            {
                PropertyChanged(this, e);
            }
        } 

        #endregion INotifyPropertyChanged 
 
        #region Protected Properties
 
        //------------------------------------------------------
        //
        //  Protected Properties
        // 
        //------------------------------------------------------
 
        ///  
        /// The items of the group.
        /// Derived classes can add or remove items using this property; 
        /// the changes will be reflected in the public Items property.
        /// 
        protected ObservableCollection ProtectedItems
        { 
            get { return _itemsRW; }
        } 
 
        /// 
        /// The number of data items (leaves) in the subtree under this group. 
        /// Derived classes can change the count using this property;
        /// the changes will be reflected in the public ItemCount property.
        /// 
        protected int ProtectedItemCount 
        {
            get { return _itemCount; } 
            set 
            {
                _itemCount = value; 
                OnPropertyChanged(new PropertyChangedEventArgs("ItemCount"));
            }
        }
 
        #endregion Protected Properties
 
        #region Private Fields 

        //----------------------------------------------------- 
        //
        //  Private Fields
        //
        //------------------------------------------------------ 

        object                                  _name; 
        ObservableCollection            _itemsRW; 
        ReadOnlyObservableCollection    _itemsRO;
        int                                     _itemCount; 

        #endregion Private Fields
    }
} 


// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
                        

                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK