Пример #1
0
        IRawElementProviderSimple IGridProvider.GetItem(int row, int column)
        {
            if (m_dataGridContext == null)
            {
                return(null);
            }

            // Here we only consider data item.  No header / footer are part of the IGridProvider.
            CollectionView items = m_dataGridContext.Items;

            if ((row < 0) || (row >= items.Count))
            {
                throw new ArgumentOutOfRangeException("row");
            }

            ReadOnlyObservableCollection <ColumnBase> visibleColumns = m_dataGridContext.VisibleColumns;

            if ((column < 0) || (column >= visibleColumns.Count))
            {
                throw new ArgumentOutOfRangeException("column");
            }

            object item = m_dataGridContext.Items.GetItemAt(row);
            DataGridItemAutomationPeer itemPeer = m_dataChildren[item] as DataGridItemAutomationPeer;

            if (itemPeer == null)
            {
                // If the item is not found in the cache, try to force is creation in the caching.
                CollectionViewGroup[] groups;
                this.GetParentGroupsContainingItemIndex(row, out groups);

                this.ForceChildrenCaching(groups);
                itemPeer = m_dataChildren[item] as DataGridItemAutomationPeer;
            }

            if (itemPeer == null)
            {
                return(null);
            }

            DataGridItemCellAutomationPeer cellPeer = itemPeer.GetDataGridItemCellPeer(visibleColumns[column]);

            if (cellPeer == null)
            {
                return(null);
            }

            return(this.ProviderFromPeer(cellPeer));
        }
Пример #2
0
        protected override List <AutomationPeer> GetChildrenCore()
        {
            DataRow dataRow = m_dataGridContext.CustomItemContainerGenerator.ContainerFromItem(m_item) as DataRow;

            if (dataRow == null)
            {
                return(null);
            }

            // Get child context ( Detail )
            DetailConfigurationCollection detailConfigurations = m_dataGridContext.DetailConfigurations;
            int detailConfigurationsCount = detailConfigurations.Count;

            ReadOnlyObservableCollection <ColumnBase> visibleColumns = m_dataGridContext.VisibleColumns;
            int visibleColumnsCount = visibleColumns.Count;

            if (visibleColumnsCount + detailConfigurationsCount <= 0)
            {
                return(null);
            }

            Hashtable             oldDataChildren = m_dataChildren;
            List <AutomationPeer> list            = new List <AutomationPeer>(visibleColumnsCount + detailConfigurationsCount);

            m_dataChildren = new Hashtable(visibleColumnsCount + detailConfigurationsCount);

            for (int i = 0; i < visibleColumnsCount; i++)
            {
                ColumnBase column = visibleColumns[i];

                DataGridItemCellAutomationPeer cellAutomationPeer =
                    oldDataChildren[column] as DataGridItemCellAutomationPeer;

                if (cellAutomationPeer == null)
                {
                    cellAutomationPeer = new DataGridItemCellAutomationPeer(this, column);
                }

                // Always resetting the ColumnIndex since the visible position can have changed
                cellAutomationPeer.ColumnIndex = i;

                list.Add(cellAutomationPeer);
                m_dataChildren[column] = cellAutomationPeer;
            }

            for (int i = 0; i < detailConfigurationsCount; i++)
            {
                DetailConfiguration           detailConfiguration = detailConfigurations[i];
                DataGridContextAutomationPeer detailDataGridContextAutomationPeer = null;

                detailDataGridContextAutomationPeer =
                    oldDataChildren[detailConfiguration] as DataGridContextAutomationPeer;

                if (detailDataGridContextAutomationPeer == null)
                {
                    detailDataGridContextAutomationPeer = new DataGridContextAutomationPeer(
                        m_dataGridContext.DataGridControl, m_dataGridContext, m_item, detailConfiguration);
                }

                list.Add(detailDataGridContextAutomationPeer);
                m_dataChildren[detailConfiguration] = detailDataGridContextAutomationPeer;
            }

            return(list);
        }