Hello, Your main purpose is to determine if the point will be in the frame, right? If so, you could try to get the left top point of the frame, and calculate the position of the frame, then judge if the (1,7) point is in the position of frame.
For example:
public Point GetScreenCoords( VisualElement view)
{//Get the point in screen, or you can get the Offset in the Parent view according to your needs.
var result = new Point(view.X, view.Y);
while (view.Parent is VisualElement parent)
{
result = result.Offset(parent.X, parent.Y);
view = parent;
}
return result;
}
private void OnCounterClicked(object sender, EventArgs e)
{
var result = GetScreenCoords(MyFrame);
double a = result.X + MyFrame.Width;
double b = result.Y + MyFrame.Height;//calculate the range
if ((result.X<1 && 1 < a) && (result.Y<7 && 7< b))
{
Console.WriteLine("Specified position is already in use.");
}
}
Best Regards, Wenyan Zhang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.