private void TreeListView_KeyUp(object sender, KeyEventArgs e) { if (e.Key == Key.Delete || e.Key == Key.Back) { TreeListView view = (TreeListView)sender; PackageSourceInfo source = (PackageSourceInfo)view.DataContext; PackageFileSourceInfo info = view.SelectedItem as PackageFileSourceInfo; if (info != source.Root && info != null) { info.Parent.Children.Remove(info); view.Focus(); } // Enabling/Disabling the Build button depending if the package is empty or not var pkgInfo = (PackageSourceInfo)DataContext; BuildButton.IsEnabled = (pkgInfo.Root.Children.Count > 0); } }
/// <summary> /// Places the subitem into edit mode /// </summary> /// <param name="column">Number of the subitem to edit</param> public void BeginEdit(int column) { if (TreeListView == null) { throw (new Exception("The item is not associated with a TreeListView")); } if (!TreeListView.Visible) { throw (new Exception("The item is not visible")); } if (column + 1 > TreeListView.Columns.Count) { throw (new Exception("The column is greater the number of columns in the TreeListView")); } TreeListView.Focus(); Focused = true; TreeListView._lastitemclicked = new EditItemInformations(this, column, this.SubItems[column].Text); base.BeginEdit(); }
public void PointToNode() { // This is the node to point to, might change, see comments // below. BrowserTreeNode node = this; TreeListView tree = (TreeListView)TreeView; if (!IsVisible) { // Ensure visible may cause a node above us to // be Invalidated() and therefore leaving this // node as an orphan. Should this happen, we need to // Find the correct node. String savePath = FullPath; EnsureVisible(); // We got invalidated, refind the right node by name if (TreeView == null) { node = (BrowserTreeNode)tree.FindNodeByFullPath(savePath); // Should not happen if (node == null) { ErrorDialog.Show("(bug) node " + savePath + " not found in PointToNode", "Error Finding Node", MessageBoxIcon.Error); return; } } } // If the node was previously selected, we need to // force the selection processing again because focus // may have gone elsewhere requiring the detail panel to // get reset. Need a better way to handle this. if (tree.SelectedNode == node) { DetailPanel.Clear(); node.Select(); } tree.SetSelectedNode(node); tree.Focus(); }
private void TreeListView_KeyUp(object sender, KeyEventArgs e) { if (e.Key == Key.Delete || e.Key == Key.Back) { TreeListView view = (TreeListView)sender; //data context of the view is multibinding to two objects - the first one is the packageBuilder, //the second one is that currentState (so that when it changes the view gets notification) List <object> values = view.DataContext as List <object>; if (values != null) { PackageBuilderViewModel viewModel = (PackageBuilderViewModel)values[0]; PackageSourceInfo source = viewModel.PackageSourceInfo; PackageFileSourceInfo info = view.SelectedItem as PackageFileSourceInfo; if (info != source.Root && info != null) { info.Parent.Children.Remove(info); view.Focus(); } } } }