本文整理汇总了C#中System.Windows.Controls.TreeView.InputHitTest方法的典型用法代码示例。如果您正苦于以下问题:C# TreeView.InputHitTest方法的具体用法?C# TreeView.InputHitTest怎么用?C# TreeView.InputHitTest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.TreeView
的用法示例。
在下文中一共展示了TreeView.InputHitTest方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetTreeViewItemFromPoint
// 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;
}
示例2: GetHoveredTreeViewItem
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;
}
示例3: GetTreeViewItemClicked
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;
}
示例4: GetExplorerTreeItem
private ProfileExplorerTreeItem GetExplorerTreeItem(TreeView treeView, Point location)
{
IInputElement targetElement = treeView.InputHitTest(location);
return GetExplorerTreeItem((UIElement)targetElement);
}
示例5: CommonPreviewMouseMove
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);
}
}
}
}
}