internal void UpdateRowData(TreeGridNodeReference newNodeReference, bool isCurrent, bool isSelected) { if (this.nodeReference != null) { this.nodeReference.Dispose(); } this.ignoreIsExpandedChanges = true; try { // NOTE: Since we keep this reference we must Clone it. this.nodeReference = newNodeReference.Clone(); this.IsCurrent = isCurrent; this.IsSelected = isSelected; this.ExpansionLevel = newNodeReference.ExpansionLevel; this.IsExpanded = newNodeReference.IsExpanded; this.RowData = newNodeReference.Item; } finally { this.ignoreIsExpandedChanges = false; } }
public void SetCurrentNode(TreeGridNodeReference node) { if (this.currentNode != null) { if (this.currentRow != null) { this.currentRow.IsCurrent = false; this.currentRow = null; } this.currentNode.Dispose(); } if (node != null) { this.currentNode = node.Clone(); this.currentRow = this.visibleRows.FirstOrDefault(r => r.NodeReference.Equals(this.currentNode)); if (this.currentRow != null) { this.currentRow.IsCurrent = true; } } else { this.currentNode = null; } RaiseCurrentItemChanged(); }
void AddNodeToSelection(TreeGridNodeReference node) { using (new SelectionChangeSuppressor(this)) { // Must clone the node (creating the active reference)... var selectedNode = node.Clone(); // ...and then be SURE that the clone is used for both the key AND the value. The value is what we // dispose when this node is removed from the selection, and the key must not get disposed while it // is used as a key (because, again, disposal alters the value semantics). this.selectedNodeReferences.Add(selectedNode, selectedNode); this.SelectedItemCount = this.selectedNodeReferences.Count; this.changeSuppressor.RegisterSelectionChange(); } }