public InteractionInfo GetInteractionInfoAtLocation(int skeletonTrackingId, InteractionHandType handType, double x, double y) { var interactionInfo = new InteractionInfo { IsPressTarget = false, IsGripTarget = false, }; var hitTestPosition = InteractionZoneDefinition.InteractionZoneToElement(x, y, this.InteractionRootElement); Func <HandPointer, bool> isTargetCapturedElement = handPointer => (handPointer.TrackingId == skeletonTrackingId) && (handPointer.HandType == EnumHelper.ConvertHandType(handType)) && (handPointer.Captured != null); var targetHandPointer = this.publicHandPointers.FirstOrDefault(isTargetCapturedElement); var targetElement = targetHandPointer != null ? targetHandPointer.Captured : this.HitTest(hitTestPosition); if (targetElement != null) { // Walk up the tree and try to find a grip target and/or a press target for (DependencyObject search = targetElement; search != null && search != this.InteractionRootElement && (!interactionInfo.IsGripTarget || !interactionInfo.IsPressTarget); search = VisualTreeHelper.GetParent(search)) { var searchElement = search as FrameworkElement; if (searchElement == null) { // We need ActualWidth and Height which comes // with FrameworkElement continue; } if (!interactionInfo.IsPressTarget) { bool isPressTarget = KinectRegion.GetIsPressTarget(searchElement); if (isPressTarget) { // We found a press target. if (interactionInfo.PressTargetControlId == 0) { interactionInfo.PressTargetControlId = searchElement.GetHashCode(); } interactionInfo.IsPressTarget = true; // Apply the margin to the press target point Point pressTargetPoint = ApplyControlPressPointMargin(KinectRegion.GetPressTargetPoint(searchElement)); // Convert from interaction zone space into actual control coordinates var elementPressTargetPoint = InteractionZoneDefinition.InteractionZoneToElement( pressTargetPoint.X, pressTargetPoint.Y, searchElement); // Get it into the space of the KinectRegion var regionPressTargetPoint = searchElement.TranslatePoint(elementPressTargetPoint, this.InteractionRootElement); // Now put it into the interaction zone space but now relative to the KinectRegion var interactionPressTargetPoint = InteractionZoneDefinition.ElementToInteractionZone( regionPressTargetPoint.X, regionPressTargetPoint.Y, this.InteractionRootElement); interactionInfo.PressAttractionPointX = interactionPressTargetPoint.X; interactionInfo.PressAttractionPointY = interactionPressTargetPoint.Y; } } if (!interactionInfo.IsGripTarget) { bool isGripTarget = KinectRegion.GetIsGripTarget(searchElement); if (isGripTarget) { // We found a grip target. interactionInfo.IsGripTarget = true; } } } } return(interactionInfo); }