当前位置: 首页>>代码示例>>C#>>正文


C# ItemsControl.InputHitTest方法代码示例

本文整理汇总了C#中System.Windows.Controls.ItemsControl.InputHitTest方法的典型用法代码示例。如果您正苦于以下问题:C# ItemsControl.InputHitTest方法的具体用法?C# ItemsControl.InputHitTest怎么用?C# ItemsControl.InputHitTest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Controls.ItemsControl的用法示例。


在下文中一共展示了ItemsControl.InputHitTest方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetElementFromPoint

 private static object GetElementFromPoint(ItemsControl box, Point point)
 {
     var element = (UIElement)box.InputHitTest(point);
     while (true) {
         if (element == box) {
             return null;
         }
         var item = box.ItemContainerGenerator.ItemFromContainer(element);
         var itemFound = !(item.Equals(DependencyProperty.UnsetValue));
         if (itemFound) {
             return item;
         }
         element = (UIElement)VisualTreeHelper.GetParent(element);
     }
 }
开发者ID:genesissupsup,项目名称:FreddiChat,代码行数:15,代码来源:MainWindow.xaml.cs

示例2: GetObjectDataFromPoint

 public static object GetObjectDataFromPoint(ItemsControl source, Point point)
 {
     UIElement element = source.InputHitTest(point) as UIElement;
     if (element != null)
     {
         object data = DependencyProperty.UnsetValue;
         while (data == DependencyProperty.UnsetValue)
         {
             data = source.ItemContainerGenerator.ItemFromContainer(element);
             if (data == DependencyProperty.UnsetValue)
                 element = VisualTreeHelper.GetParent(element) as UIElement;
             if (element == source)
                 return null;
         }
         if (data != DependencyProperty.UnsetValue)
             return data;
     }
     return null;
 }
开发者ID:tica,项目名称:DataFlow,代码行数:19,代码来源:WPFHelpers.cs

示例3: GetDataObjectFromItemsControl

        public static object GetDataObjectFromItemsControl(ItemsControl itemsControl, Point p)
        {
            UIElement element = itemsControl.InputHitTest(p) as UIElement;
            while (element != null)
            {
                if (element == itemsControl)
                    return null;

                object data = itemsControl.ItemContainerGenerator.ItemFromContainer(element);
                if (data != DependencyProperty.UnsetValue)
                {
                    return data;
                }
                else
                {
                    element = VisualTreeHelper.GetParent(element) as UIElement;
                }
            }
            return null;
        }
开发者ID:allanckw,项目名称:GEMS-Client,代码行数:20,代码来源:Helper.cs

示例4: FindGroup

        private CollectionViewGroup FindGroup(ItemsControl itemsControl, Point position)
        {
            var element = itemsControl.InputHitTest(position) as DependencyObject;

              if (element != null) {
            var groupItem = element.GetVisualAncestor<GroupItem>();

            if (groupItem != null) {
              return groupItem.Content as CollectionViewGroup;
            }
              }

              return null;
        }
开发者ID:GeoffEngelstein,项目名称:gong-wpf-dragdrop,代码行数:14,代码来源:DropInfo.cs

示例5: GetElementFromPoint

 /// <summary>
 /// 获取鼠标位置的元素
 /// </summary>
 /// <param name="itemsControl"></param>
 /// <param name="point"></param>
 /// <returns></returns>
 private object GetElementFromPoint(ItemsControl itemsControl, Point point)
 {
     UIElement element = itemsControl.InputHitTest(point) as UIElement;
     while (element != null)
     {
         if (Equals(element, itemsControl))
             return null;
         object item = itemsControl.ItemContainerGenerator.ItemFromContainer(element);
         if (!item.Equals(DependencyProperty.UnsetValue))
             return item;
         element = (UIElement)VisualTreeHelper.GetParent(element);
     }
     return null;
 }
开发者ID:HADB,项目名称:ListManager,代码行数:20,代码来源:MainWindow.xaml.cs


注:本文中的System.Windows.Controls.ItemsControl.InputHitTest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。