Esempio n. 1
0
        internal DataGridGroupItemAutomationPeer GetOrCreateGroupItemPeer(object group)
        {
            DataGridGroupItemAutomationPeer peer = null;

            if (group != null)
            {
                if (_groupItemPeers.ContainsKey(group))
                {
                    peer = _groupItemPeers[group];
                }
                else
                {
                    peer = new DataGridGroupItemAutomationPeer(group as ICollectionViewGroup, this.OwningDataGrid);
                    _groupItemPeers.Add(group, peer);
                }

                DataGridRowGroupHeaderAutomationPeer rghPeer = peer.OwningRowGroupHeaderPeer;
                if (rghPeer != null)
                {
                    rghPeer.EventsSource = peer;
                }
            }

            return(peer);
        }
Esempio n. 2
0
        internal void UpdateRowGroupHeaderPeerEventsSource(DataGridRowGroupHeader header)
        {
            object group = header.RowGroupInfo.CollectionViewGroup;
            DataGridRowGroupHeaderAutomationPeer peer = DataGridRowGroupHeaderAutomationPeer.FromElement(header) as DataGridRowGroupHeaderAutomationPeer;

            if (peer != null && group != null && _groupItemPeers.ContainsKey(group))
            {
                peer.EventsSource = _groupItemPeers[group];
            }
        }
Esempio n. 3
0
        internal void PopulateGroupItemPeers()
        {
            Dictionary <object, DataGridGroupItemAutomationPeer> oldChildren = new Dictionary <object, DataGridGroupItemAutomationPeer>(_groupItemPeers);

            _groupItemPeers.Clear();

            if (this.OwningDataGrid.DataConnection.CollectionView != null &&
#if FEATURE_ICOLLECTIONVIEW_GROUP
                this.OwningDataGrid.DataConnection.CollectionView.CanGroup &&
#endif
                this.OwningDataGrid.DataConnection.CollectionView.CollectionGroups != null &&
                this.OwningDataGrid.DataConnection.CollectionView.CollectionGroups.Count > 0)
            {
                List <object> groups = new List <object>(this.OwningDataGrid.DataConnection.CollectionView.CollectionGroups);
                while (groups.Count > 0)
                {
                    ICollectionViewGroup cvGroup = groups[0] as ICollectionViewGroup;
                    groups.RemoveAt(0);
                    if (cvGroup != null)
                    {
                        // Add the group's peer to the collection
                        DataGridGroupItemAutomationPeer peer = null;

                        if (oldChildren.ContainsKey(cvGroup))
                        {
                            peer = oldChildren[cvGroup] as DataGridGroupItemAutomationPeer;
                        }
                        else
                        {
                            peer = new DataGridGroupItemAutomationPeer(cvGroup, this.OwningDataGrid);
                        }

                        if (peer != null)
                        {
                            DataGridRowGroupHeaderAutomationPeer rghPeer = peer.OwningRowGroupHeaderPeer;
                            if (rghPeer != null)
                            {
                                rghPeer.EventsSource = peer;
                            }
                        }

                        // This guards against the addition of duplicate items
                        if (!_groupItemPeers.ContainsKey(cvGroup))
                        {
                            _groupItemPeers.Add(cvGroup, peer);
                        }

#if FEATURE_ICOLLECTIONVIEW_GROUP
                        // Look for any sub groups
                        if (!cvGroup.IsBottomLevel)
                        {
                            int position = 0;
                            foreach (object subGroup in cvGroup.Items)
                            {
                                groups.Insert(position, subGroup);
                                position++;
                            }
                        }
#endif
                    }
                }
            }
        }