Hi,@HoWe Yu. Welcome to Microsoft Q&A.
To achieve the effect you want, you only need to strictly constrain the execution condition of MainPopup.IsOpen = false;
You could determine whether the mouse has left the Grid area in MainGrid_MouseLeave
private void MainGrid_MouseLeave(object sender, MouseEventArgs e)
{
Point point = Mouse.GetPosition(MainGrid);
if (point.X>MainGrid.Width&&point.Y<MainGrid.Height)
{
MainPopup.IsOpen = false;
}
}
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.