/// protected override List <AutomationPeer> GetChildrenCore() { ListView listview = _listviewAP.Owner as ListView; Invariant.Assert(listview != null); object item = Item; ListViewItem lvi = listview.ItemContainerGenerator.ContainerFromItem(item) as ListViewItem; if (lvi != null) { GridViewRowPresenter rowPresenter = GridViewAutomationPeer.FindVisualByType(lvi, typeof(GridViewRowPresenter)) as GridViewRowPresenter; if (rowPresenter != null) { Hashtable oldChildren = _dataChildren; //cache the old ones for possible reuse _dataChildren = new Hashtable(rowPresenter.ActualCells.Count); List <AutomationPeer> list = new List <AutomationPeer>(); int row = listview.Items.IndexOf(item); int column = 0; foreach (UIElement ele in rowPresenter.ActualCells) { GridViewCellAutomationPeer peer = (oldChildren == null ? null : (GridViewCellAutomationPeer)oldChildren[ele]); if (peer == null) { if (ele is ContentPresenter) { peer = new GridViewCellAutomationPeer((ContentPresenter)ele, _listviewAP); } else if (ele is TextBlock) { peer = new GridViewCellAutomationPeer((TextBlock)ele, _listviewAP); } else { Invariant.Assert(false, "Children of GridViewRowPresenter should be ContentPresenter or TextBlock"); } } //protection from indistinguishable UIElement - for example, 2 UIElement wiht same value if (_dataChildren[ele] == null) { //Set Cell's row and column peer.Column = column; peer.Row = row; list.Add(peer); _dataChildren.Add(ele, peer); column++; } } return(list); } } return(null); }
/// <summary>Gets the collection of child elements of the <see cref="P:System.Windows.Controls.ItemsControl.Items" /> collection that is associated with this <see cref="T:System.Windows.Automation.Peers.GridViewItemAutomationPeer" />. Called by <see cref="M:System.Windows.Automation.Peers.AutomationPeer.GetChildren" />.</summary> /// <returns>The collection of child elements.</returns> // Token: 0x060026DE RID: 9950 RVA: 0x000B8264 File Offset: 0x000B6464 protected override List <AutomationPeer> GetChildrenCore() { ListView listView = this._listviewAP.Owner as ListView; Invariant.Assert(listView != null); object item = base.Item; ListViewItem listViewItem = listView.ItemContainerGenerator.ContainerFromItem(item) as ListViewItem; if (listViewItem != null) { GridViewRowPresenter gridViewRowPresenter = GridViewAutomationPeer.FindVisualByType(listViewItem, typeof(GridViewRowPresenter)) as GridViewRowPresenter; if (gridViewRowPresenter != null) { Hashtable dataChildren = this._dataChildren; this._dataChildren = new Hashtable(gridViewRowPresenter.ActualCells.Count); List <AutomationPeer> list = new List <AutomationPeer>(); int row = listView.Items.IndexOf(item); int num = 0; foreach (UIElement uielement in gridViewRowPresenter.ActualCells) { GridViewCellAutomationPeer gridViewCellAutomationPeer = (dataChildren == null) ? null : ((GridViewCellAutomationPeer)dataChildren[uielement]); if (gridViewCellAutomationPeer == null) { if (uielement is ContentPresenter) { gridViewCellAutomationPeer = new GridViewCellAutomationPeer((ContentPresenter)uielement, this._listviewAP); } else if (uielement is TextBlock) { gridViewCellAutomationPeer = new GridViewCellAutomationPeer((TextBlock)uielement, this._listviewAP); } else { Invariant.Assert(false, "Children of GridViewRowPresenter should be ContentPresenter or TextBlock"); } } if (this._dataChildren[uielement] == null) { gridViewCellAutomationPeer.Column = num; gridViewCellAutomationPeer.Row = row; list.Add(gridViewCellAutomationPeer); this._dataChildren.Add(uielement, gridViewCellAutomationPeer); num++; } } return(list); } } return(null); }
// Token: 0x060026B6 RID: 9910 RVA: 0x000B7E8C File Offset: 0x000B608C internal static Visual FindVisualByType(Visual parent, Type type) { if (parent != null) { int internalVisualChildrenCount = parent.InternalVisualChildrenCount; for (int i = 0; i < internalVisualChildrenCount; i++) { Visual visual = parent.InternalGetVisualChild(i); if (!type.IsInstanceOfType(visual)) { visual = GridViewAutomationPeer.FindVisualByType(visual, type); } if (visual != null) { return(visual); } } } return(null); }