本文整理汇总了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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}