// Static Methods
 private static TreeViewItem GetTreeViewItemFromPoint(TreeView treeView, Point point)
 {
     DependencyObject obj = treeView.InputHitTest(point) as DependencyObject;
     while (obj != null && !(obj is TreeViewItem))
         obj = VisualTreeHelper.GetParent(obj);
     return obj as TreeViewItem;
 }
Example #2
0
 private SiteExplorerNodeViewModel GetHoveredTreeViewItem(DragEventArgs e, TreeView tvw)
 {
     DependencyObject elem = tvw.InputHitTest(e.GetPosition(tvw)) as DependencyObject;
     while (elem != null && !(elem is TreeViewItem)) {
         elem = VisualTreeHelper.GetParent(elem);
     }
     var treeItem = elem as TreeViewItem;
     if (treeItem != null) {
         treeItem.Focus();
         return treeItem.DataContext as SiteExplorerNodeViewModel;
     }
     return null;
 }
Example #3
0
 private TreeViewItem GetTreeViewItemClicked(FrameworkElement sender, TreeView treeView)
 {
     Point p = sender.TranslatePoint(new Point(1, 1), treeView);
     DependencyObject obj = treeView.InputHitTest(p) as DependencyObject;
     while (obj != null && !(obj is TreeViewItem)) {
         obj = VisualTreeHelper.GetParent(obj);
     }
     return obj as TreeViewItem;
 }
 private ProfileExplorerTreeItem GetExplorerTreeItem(TreeView treeView, Point location)
 {
     IInputElement targetElement = treeView.InputHitTest(location);
     return GetExplorerTreeItem((UIElement)targetElement);
 }
Example #5
0
        private void CommonPreviewMouseMove(MouseEventArgs e, TreeView treeView)
        {
            if (_startPoint == null) {
                return;
            }

            if (e.LeftButton == MouseButtonState.Pressed && !_IsDragging) {
                Point position = e.GetPosition(treeView);
                if (Math.Abs(position.X - _startPoint.X) > SystemParameters.MinimumHorizontalDragDistance || Math.Abs(position.Y - _startPoint.Y) > SystemParameters.MinimumVerticalDragDistance) {
                    if (treeView.SelectedItem != null) {
                        IInputElement hitelement = treeView.InputHitTest(_startPoint);
                        TreeViewItem item = treeView.GetTreeViewItemClicked((FrameworkElement)hitelement);
                        if (item != null) {
                            StartDrag(e, treeView, item);
                        }
                    }
                }
            }
        }