Hello,
This is related to the initialization process of the Maui control. If you read the X and Y values directly in the page's construction method, they will be 0 because the control has not yet been assigned a position.
After the control is placed on the page, you can read its X, Y. This event corresponds to the SizeChanged
event of the control. Please refer to the following code.
TheView.SizeChanged += (s, e) =>
{
Console.WriteLine(TheView.X.ToString());
};
Best Regards,
Alec Liu.
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.