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 CollectionViewGroup, this.OwningDataGrid);
                    _groupItemPeers.Add(group, peer);
                }

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

            return(peer);
        }
Esempio n. 2
0
        internal void PopulateGroupItemPeers()
        {
            Dictionary <object, DataGridGroupItemAutomationPeer> oldChildren = new Dictionary <object, DataGridGroupItemAutomationPeer>(_groupItemPeers);

            _groupItemPeers.Clear();

            if (this.OwningDataGrid.DataConnection.CollectionView != null &&
                this.OwningDataGrid.DataConnection.CollectionView.CanGroup &&
                this.OwningDataGrid.DataConnection.CollectionView.Groups != null &&
                this.OwningDataGrid.DataConnection.CollectionView.Groups.Count > 0)
            {
                List <object> groups = new List <object>(this.OwningDataGrid.DataConnection.CollectionView.Groups);
                while (groups.Count > 0)
                {
                    CollectionViewGroup cvGroup = groups[0] as CollectionViewGroup;
                    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);
                        }

                        // Look for any sub groups
                        if (!cvGroup.IsBottomLevel)
                        {
                            int position = 0;
                            foreach (object subGroup in cvGroup.Items)
                            {
                                groups.Insert(position, subGroup);
                                position++;
                            }
                        }
                    }
                }
            }
        }
Esempio n. 3
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];
            }
        }