internal Point GetPosition(Point position, UIElement relativeTo) { if (relativeTo == this) { return(position); } var currentViewLocation = new int[2]; GetLocationInWindow(currentViewLocation); if (relativeTo == null) { return(new Point( position.X + ViewHelper.PhysicalToLogicalPixels(currentViewLocation[0]), position.Y + ViewHelper.PhysicalToLogicalPixels(currentViewLocation[1]) )); } var relativeToLocation = new int[2]; relativeTo.GetLocationInWindow(relativeToLocation); return(new Point( position.X + ViewHelper.PhysicalToLogicalPixels(currentViewLocation[0] - relativeToLocation[0]), position.Y + ViewHelper.PhysicalToLogicalPixels(currentViewLocation[1] - relativeToLocation[1]) )); }