/// <summary> /// 连接到可视父元素,连接成功,则返回 true。 /// </summary> /// <returns></returns> private bool TryConnect() { if (!this.IsConnected) { this._cellsPresenter = ItemsControl.GetItemsOwner(this) as TreeGridCellsPresenter; if (this._cellsPresenter != null) { this._cellsPresenter.InternalItemsHost = this; var row = this._cellsPresenter.Row; if (row != null) { row.CellsPanel = this; this._treeGrid = row.TreeGrid; if (this._treeGrid != null) { InternalCollectionChangedEventManager.AddListener(this._treeGrid.Columns, this); this._rowsPanel = this._treeGrid.RowsPanel; //分组显示时,RowsPanel 为 null,也不能进行虚拟化操作。 this._isVirtualizing = this._rowsPanel != null && this._treeGrid.IsColumnsVirtualizingEnabled; this._isRecycleMode = this._treeGrid.IsRecycleMode; } } } } return(this.IsConnected); }
private void Disconnect() { if (this.IsConnected) { InternalCollectionChangedEventManager.RemoveListener(this._treeGrid.Columns, this); this._rowsPanel = null; this._treeGrid = null; var row = this._cellsPresenter.Row; if (row != null) { row.CellsPanel = null; } this._cellsPresenter.InternalItemsHost = null; this._cellsPresenter = null; } }
/// <summary> /// 连接到可视父元素,连接成功,则返回 true。 /// </summary> /// <returns></returns> private bool TryConnect() { if (!this.IsConnected) { this._cellsPresenter = ItemsControl.GetItemsOwner(this) as TreeGridCellsPresenter; if (this._cellsPresenter != null) { this._cellsPresenter.InternalItemsHost = this; var row = this._cellsPresenter.Row; if (row != null) { row.CellsPanel = this; this._treeGrid = row.TreeGrid; if (this._treeGrid != null) { InternalCollectionChangedEventManager.AddListener(this._treeGrid.Columns, this); this._rowsPanel = this._treeGrid.RowsPanel; //分组显示时,RowsPanel 为 null,也不能进行虚拟化操作。 this._isVirtualizing = this._rowsPanel != null && this._treeGrid.IsColumnsVirtualizingEnabled; this._isRecycleMode = this._treeGrid.IsRecycleMode; } } } } return this.IsConnected; }